home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / usenet / sources / volume89 / graphics / mandelv2.9 < prev    next >
Internet Message Format  |  1989-06-21  |  70KB

  1. Path: xanth!ames!oliveb!sun!swap!page
  2. From: page%swap@Sun.COM (Bob Page)
  3. Newsgroups: comp.sources.amiga
  4. Subject: v89i160:  mandelvroom - mandelbrot explorer v2.0, Part09/09
  5. Message-ID: <111394@sun.Eng.Sun.COM>
  6. Date: 21 Jun 89 04:02:33 GMT
  7. Sender: news@sun.Eng.Sun.COM
  8. Lines: 2596
  9. Approved: page@sun.com
  10.  
  11. Submitted-by: kevin@uts.amdahl.com (Kevin Clague)
  12. Posting-number: Volume 89, Issue 160
  13. Archive-name: graphics/mandelv20.9
  14.  
  15. # This is a shell archive.
  16. # Remove anything above and including the cut line.
  17. # Then run the rest of the file through 'sh'.
  18. # Unpacked files will be owned by you and have default permissions.
  19. #----cut here-----cut here-----cut here-----cut here----#
  20. #!/bin/sh
  21. # shar: SHell ARchive
  22. # Run the following text through 'sh' to create:
  23. #    safeclose.h
  24. #    saveilbm.c
  25. #    saveilbm.h
  26. #    savemand.c
  27. #    scroll.c
  28. #    showhelp.c
  29. #    standard.h
  30. #    status.c
  31. #    tasks.c
  32. # This is archive 9 of a 9-part kit.
  33. # This archive created: Tue Jun 20 20:45:33 1989
  34. echo "extracting safeclose.h"
  35. sed 's/^X//' << \SHAR_EOF > safeclose.h
  36. X/* CloseWindowSafely()
  37. X*       This module should be used whenever you are sharing an IDCMP
  38. X* message port with more than one window.  Rather than calling CloseWindow(),
  39. X* you should use CloseWindowSafely().  This will keep Intuition from
  40. X* Guru Meditation, and thus is considered a good thing.  You should still
  41. X* use CloseWindow for the very last window you close.
  42. X*       The reason this is needed, is because Intuition will re-claim
  43. X* any outstanding messages for a window when the window is closed. But...
  44. X* it can't take them out of your message port. Thus, you will receive
  45. X* invalid messages and bad things will happen.  Very bad things.
  46. X*       This code is a slightly condensed version of the same routine
  47. X* written by Neil Katin of Amiga for the April '86 Commodore Developers
  48. X* Newsletter, Amiga Mail (tm).
  49. X*/
  50. X
  51. X#ifndef SAFECLOSE
  52. X
  53. X#define SAFECLOSE
  54. X
  55. X
  56. X/* CloseWindowSafely(window), window is pointer to struct Window */
  57. X
  58. Xextern void CloseWindowSafely();
  59. X
  60. X#endif
  61. X
  62. SHAR_EOF
  63. echo "extracting saveilbm.c"
  64. sed 's/^X//' << \SHAR_EOF > saveilbm.c
  65. X/***************************************************************************
  66. X*  SaveILBM.c --  Save front screen as ILBM file
  67. X*                 Saves a CAMG chunk for Amiga ViewModes
  68. X*                   by Carolyn Scheppner  CBM  10/86
  69. X*
  70. X*                   modified by Kevin L. Clague for use in Mandelbrot
  71. X*
  72. X*     Using IFF rtns by J.Morrison and S.Shaw of Electronic Arts
  73. X*
  74. X***************************************************************************/
  75. X
  76. X#include "SaveILBM.h"
  77. X
  78. X/* CAMG Stuff */
  79. Xtypedef struct {
  80. X   ULONG ViewModes;
  81. X   } CamgChunk;
  82. X
  83. X#define PutCAMG(context, camg)  \
  84. X    PutCk(context, ID_CAMG, sizeof(CamgChunk), (BYTE *)camg)
  85. X
  86. X#define ID_CRNG  MakeID('C','R','N','G')
  87. X#define PutCRNG(context, crng)  \
  88. X    PutCk(context, ID_CRNG, sizeof(CrngChunk), (BYTE *)crng)
  89. X
  90. X#define bufSize 512
  91. X
  92. Xextern struct IntuitionBase *IntuitionBase;
  93. Xextern struct Screen *screen;
  94. X
  95. Xstruct Screen   *frontScreen;
  96. X
  97. Xstruct ViewPort *picViewPort;
  98. Xstruct BitMap   *picBitMap;
  99. XWORD            *picColorTable;
  100. XULONG            picViewModes;
  101. X
  102. X/* ILBM Icon Image */
  103. X
  104. XUSHORT  ILBMimagedata[] = {
  105. X 0x0000, 0x0000, 0x0000, 0x0000,
  106. X 0x7FFF, 0xFFFF, 0xFFFF, 0xFF80,
  107. X 0x6000, 0x0000, 0x0000, 0x0180,
  108. X 0x6000, 0x07FF, 0xFFFF, 0x8180,
  109. X 0x6000, 0x401F, 0xFFC0, 0x0180,
  110. X 0x6002, 0xE000, 0x0000, 0x0180,
  111. X 0x6003, 0x6002, 0x0008, 0x0180,
  112. X 0x600B, 0xF807, 0x005E, 0x0180,
  113. X 0x6001, 0xFC03, 0x809F, 0x8180,
  114. X 0x6000, 0x0E07, 0xC2FF, 0xE180,
  115. X 0x600D, 0xAF05, 0xE017, 0xF980,
  116. X 0x6021, 0x2F83, 0xC057, 0xF980,
  117. X 0x6025, 0xFF1F, 0x24C7, 0xF980,
  118. X 0x6097, 0xFA6E, 0x881F, 0xF980,
  119. X 0x601E, 0xFCEC, 0x3B5B, 0xF980,
  120. X 0x6055, 0xFFBA, 0x559F, 0xF980,
  121. X 0x60EF, 0xFFFF, 0xFFFF, 0xF980,
  122. X 0x6000, 0x0000, 0x0000, 0x0180,
  123. X 0x7FFF, 0xFFFF, 0xFFFF, 0xFF80,
  124. X 0x0000, 0x0000, 0x0000, 0x0000,
  125. X/**/
  126. X 0xFFFF, 0xFFFF, 0xFFFF, 0xFFC0,
  127. X 0x8000, 0x0000, 0x0000, 0x0040,
  128. X 0x9FFF, 0xFFFF, 0xFFFF, 0xFE40,
  129. X 0x9800, 0x0000, 0x0000, 0x0640,
  130. X 0x9800, 0x0000, 0x0000, 0x0640,
  131. X 0x9801, 0x0000, 0x0000, 0x0640,
  132. X 0x9804, 0x8004, 0x0000, 0x0640,
  133. X 0x9804, 0x8008, 0x0020, 0x0640,
  134. X 0x981F, 0x0C0C, 0x0160, 0x0640,
  135. X 0x983F, 0xFE1F, 0x8D00, 0x0640,
  136. X 0x98FF, 0xFF7F, 0xDFE8, 0x0640,
  137. X 0x9BFF, 0xFFFF, 0xFFFF, 0x0640,
  138. X 0x9FFF, 0xFFFF, 0xFFFF, 0x8640,
  139. X 0x9FFF, 0xFFFF, 0xFFFF, 0xFE40,
  140. X 0x9FFF, 0xFFFF, 0xFFFF, 0xFE40,
  141. X 0x9FFF, 0xFFFF, 0xFFFF, 0xFE40,
  142. X 0x9FFF, 0xFFFF, 0xFFFF, 0xFE40,
  143. X 0x9FFF, 0xFFFF, 0xFFFF, 0xFE40,
  144. X 0x8000, 0x0000, 0x0000, 0x0040,
  145. X 0xFFFF, 0xFFFF, 0xFFFF, 0xFFC0
  146. X/**/
  147. X };
  148. X
  149. Xstruct Image  ILBMimage[] = {
  150. X 0,  /* LeftEdge */
  151. X 0,  /* TopEdge */
  152. X 58,  /* Width */
  153. X 20,  /* Height */
  154. X 2,  /* Depth */
  155. X (USHORT *)&ILBMimagedata,  /* ImageData */
  156. X 0x3,  /* PlanePick */
  157. X 0x0,  /* PlaneOnOff */
  158. X 0  /* [NextImage] */
  159. X };
  160. X
  161. Xstruct DiskObject ILBMIcon = {
  162. X WB_DISKMAGIC,   /* do_Magic */
  163. X WB_DISKVERSION, /* do_Version */
  164. X
  165. X/* Embedded Gadget Structure */
  166. X 0,  /* [NextGadget] */
  167. X 147,  /* LeftEdge */
  168. X 23,  /* TopEdge */
  169. X 58,  /* Width */
  170. X 20,  /* Height */
  171. X 0x4,  /* Flags */
  172. X 0x3,  /* Activation */
  173. X 0x1,  /* GadgetType */
  174. X (APTR)&ILBMimage, /* GadgetRender */
  175. X NULL,     /* SelectRender */
  176. X NULL,     /* GadgetText */
  177. X 0x0,  /* MutualExclude */
  178. X 0x0,  /* [SpecialInfo] */
  179. X 0,  /* GadgetID */
  180. X 0x0,  /* [UserData] */
  181. X
  182. X/* Rest of DiskObject structure */
  183. X 0x4,  /* do_Type */
  184. X ":ViewILBM",   /* do_Default Tool */
  185. X 0xC06508,  /* [do_ToolTypes] */
  186. X NO_ICON_POSITION,  /* do_CurrentX */
  187. X NO_ICON_POSITION,  /* do_CurrentY */
  188. X 0x0,  /* [do_DrawerData] */
  189. X 0x0,  /* [do_ToolWindow] */
  190. X 0x0  /* do_StackSize */
  191. X };
  192. X
  193. X/**************************************************************************
  194. X *
  195. X *  Save the current screen as an ILBM file
  196. X *
  197. X **************************************************************************/
  198. X
  199. XSaveILBM(FileName, Crng, numCrng)
  200. X  char *FileName;
  201. X  CrngChunk *Crng;
  202. X  int numCrng;
  203. X{
  204. X  LONG            file;
  205. X  IFFP            iffp = NO_FILE;
  206. X
  207. X  int l;
  208. X
  209. X  if (!(file = Open(FileName, MODE_NEWFILE))) {
  210. X
  211. X    char Msg[80];
  212. X    sprintf(Msg,"Can't open file %s\n",FileName);
  213. X    DispErrMsg(Msg,0);
  214. X    return(0);
  215. X  }
  216. X
  217. X  Write(file,"x",1);  /* 1.1 so Seek to beginning works ? */
  218. X
  219. X  frontScreen  = screen;
  220. X
  221. X  picViewPort =  &( frontScreen->ViewPort );
  222. X  picBitMap =     (struct BitMap*)picViewPort->RasInfo->BitMap;
  223. X  picColorTable = (WORD *)picViewPort->ColorMap->ColorTable;
  224. X  picViewModes =  (ULONG)picViewPort->Modes;
  225. X
  226. X  iffp = PutPicture(file, picBitMap, picColorTable, picViewModes,
  227. X    Crng, numCrng);
  228. X  Close(file);
  229. X
  230. X  if (iffp == IFF_OKAY && FromWB ) {
  231. X
  232. X    /* This line outputs the icon */
  233. X    PutDiskObject(FileName,&ILBMIcon);
  234. X  }
  235. X} /* SaveILBM */
  236. X
  237. X
  238. X/** PutPicture() ***********************************************************
  239. X *
  240. X * Put a picture into an IFF file.
  241. X * This procedure calls PutAnILBM, passing in an <x, y> location of <0, 0>,
  242. X * a NULL mask, and a locally-allocated buffer. It also assumes you want to
  243. X * write out all the bitplanes in the BitMap.
  244. X *
  245. X ***************************************************************************/
  246. XPoint2D nullPoint = {0, 0};
  247. X
  248. XIFFP PutPicture(file, bitmap, colorMap, viewmodes, crng, numcrng)
  249. X      LONG file;  struct BitMap *bitmap;
  250. X      WORD *colorMap;  ULONG viewmodes;
  251. X      CrngChunk *crng;
  252. X      int numcrng;
  253. X   {
  254. X   BYTE buffer[bufSize];
  255. X   return( PutAnILBM(file, bitmap, NULL,
  256. X           colorMap, bitmap->Depth, viewmodes,
  257. X           &nullPoint, crng, numcrng, buffer, bufSize) );
  258. X   }
  259. X
  260. X
  261. X/** PutAnILBM() ************************************************************
  262. X *
  263. X * Write an entire BitMap as a FORM ILBM in an IFF file.
  264. X * This version works for any display mode (C. Scheppner).
  265. X *
  266. X * Normal return result is IFF_OKAY.
  267. X *
  268. X * The utility program IFFCheck would print the following outline of the
  269. X * resulting file:
  270. X *
  271. X *   FORM ILBM
  272. X *     BMHD
  273. X *     CAMG
  274. X *     CMAP
  275. X *     CRNG
  276. X *     CRNG
  277. X *     CRNG
  278. X *     CRNG
  279. X *     BODY       (compressed)
  280. X *
  281. X ***************************************************************************/
  282. X#define CkErr(expression)  {if (ifferr == IFF_OKAY) ifferr = (expression);}
  283. X
  284. XIFFP PutAnILBM(file, bitmap, mask, colorMap, depth,
  285. X                                viewmodes, xy, crng, numcrng,
  286. X                                buffer, bufsize)
  287. X      LONG file;
  288. X      struct BitMap *bitmap;
  289. X      BYTE *mask;  WORD *colorMap; UBYTE depth;
  290. X      ULONG viewmodes;
  291. X      Point2D *xy; BYTE *buffer;  LONG bufsize;
  292. X      CrngChunk *crng;
  293. X      int numcrng;
  294. X   {
  295. X   BitMapHeader bmHdr;
  296. X   CamgChunk    camgChunk;
  297. X   GroupContext fileContext, formContext;
  298. X   IFFP ifferr;
  299. X   WORD pageWidth, pageHeight;
  300. X   int i;
  301. X
  302. X   pageWidth  = (bitmap->BytesPerRow) << 3;
  303. X   pageHeight = bitmap->Rows;
  304. X
  305. X   ifferr = InitBMHdr(&bmHdr, bitmap, mskNone,
  306. X                      cmpByteRun1, 0, pageWidth, pageHeight);
  307. X   /* You could write an uncompressed image by passing cmpNone instead
  308. X    * of cmpByteRun1 to InitBMHdr. */
  309. X   bmHdr.nPlanes = depth;   /* This must be  <= bitmap->Depth */
  310. X   if (mask != NULL) bmHdr.masking = mskHasMask;
  311. X   bmHdr.x = xy->x;   bmHdr.y = xy->y;
  312. X
  313. X   camgChunk.ViewModes = viewmodes;
  314. X
  315. X   CkErr( OpenWIFF(file, &fileContext, szNotYetKnown) );
  316. X   CkErr(StartWGroup(&fileContext, FORM, szNotYetKnown, ID_ILBM, &formContext));
  317. X
  318. X   CkErr( PutBMHD(&formContext, &bmHdr) );
  319. X   CkErr( PutCAMG(&formContext, &camgChunk) );
  320. X   CkErr( PutCMAP(&formContext, colorMap, depth) );
  321. X
  322. X   for (i = 0; i < numcrng; i++) {
  323. X     CkErr( PutCRNG(&formContext, &crng[i]));
  324. X   }
  325. X   CkErr( PutBODY(&formContext, bitmap, mask, &bmHdr, buffer, bufsize) );
  326. X
  327. X   CkErr( EndWGroup(&formContext) );
  328. X   CkErr( CloseWGroup(&fileContext) );
  329. X   return( ifferr );
  330. X   }
  331. X
  332. X
  333. SHAR_EOF
  334. echo "extracting saveilbm.h"
  335. sed 's/^X//' << \SHAR_EOF > saveilbm.h
  336. X/*
  337. X * MandelVroom 2.0
  338. X *
  339. X * (c) Copyright 1987,1989  Kevin L. Clague, San Jose, CA
  340. X *
  341. X * All rights reserved.
  342. X *
  343. X * Permission is hereby granted to distribute this program's source
  344. X * executable, and documentation for non-comercial purposes, so long as the
  345. X * copyright notices are not removed from the sources, executable or
  346. X * documentation.  This program may not be distributed for a profit without
  347. X * the express written consent of the author Kevin L. Clague.
  348. X *
  349. X * This program is not in the public domain.
  350. X *
  351. X * Fred Fish is expressly granted permission to distribute this program's
  352. X * source and executable as part of the "Fred Fish freely redistributable
  353. X * Amiga software library."
  354. X *
  355. X * Permission is expressly granted for this program and it's source to be
  356. X * distributed as part of the Amicus Amiga software disks, and the
  357. X * First Amiga User Group's Hot Mix disks.
  358. X *
  359. X * contents: includes required by SaveILBM.c
  360. X */
  361. X
  362. X#include "mandp.h"
  363. X#include <libraries/dos.h>
  364. X#include <graphics/rastport.h>
  365. X#include <graphics/view.h>
  366. SHAR_EOF
  367. echo "extracting savemand.c"
  368. sed 's/^X//' << \SHAR_EOF > savemand.c
  369. X/*
  370. X * MandelVroom 2.0
  371. X *
  372. X * (c) Copyright 1987,1989  Kevin L. Clague, San Jose, CA
  373. X *
  374. X * All rights reserved.
  375. X *
  376. X * Permission is hereby granted to distribute this program's source
  377. X * executable, and documentation for non-comercial purposes, so long as the
  378. X * copyright notices are not removed from the sources, executable or
  379. X * documentation.  This program may not be distributed for a profit without
  380. X * the express written consent of the author Kevin L. Clague.
  381. X *
  382. X * This program is not in the public domain.
  383. X *
  384. X * Fred Fish is expressly granted permission to distribute this program's
  385. X * source and executable as part of the "Fred Fish freely redistributable
  386. X * Amiga software library."
  387. X *
  388. X * Permission is expressly granted for this program and it's source to be
  389. X * distributed as part of the Amicus Amiga software disks, and the
  390. X * First Amiga User Group's Hot Mix disks.
  391. X *
  392. X * contents: this file contains the functions to save projects to disk,
  393. X * load projects from disk, and save icon files (if the program was started
  394. X * from the WorkBench.)
  395. X */
  396. X
  397. X#include "mandp.h"
  398. X
  399. Xextern struct NewScreen NewScreen;
  400. X
  401. Xextern ULONG CalcTime;
  402. X
  403. Xextern BYTE FromWB;
  404. X
  405. X       ULONG BorderType;
  406. X
  407. XUSHORT  MandimageData1[] = {
  408. X 0xFFFF, 0xFFFF, 0xFFFF, 0xFFC0,
  409. X 0xFFFF, 0xFFFF, 0xFFFF, 0xFFC0,
  410. X 0xFFFF, 0xFFE3, 0xFFFF, 0xFFC0,
  411. X 0xFFFF, 0xF101, 0x67FF, 0xFFC0,
  412. X 0xFFF8, 0x7040, 0xC0F7, 0xFFC0,
  413. X 0xF9D4, 0x4441, 0x414B, 0xFFC0,
  414. X 0xF80F, 0x0F79, 0x8403, 0xFFC0,
  415. X 0xDA0F, 0xFFFF, 0xEC01, 0xFFC0,
  416. X 0x9743, 0xFFFF, 0xFE46, 0x0FC0,
  417. X 0x8FFF, 0xFFFF, 0xFF80, 0x3FC0,
  418. X 0xF03F, 0xFFEF, 0xFFC0, 0x7FC0,
  419. X 0xB7FF, 0xFE00, 0x3F91, 0xDFC0,
  420. X 0xFFFF, 0xF878, 0x3FC0, 0x07C0,
  421. X 0x8FFF, 0xF8F0, 0x7F80, 0x17C0,
  422. X 0xB7FF, 0xF0FF, 0xFFC0, 0x3FC0,
  423. X 0xFFFF, 0xF83F, 0xFC03, 0x7FC0,
  424. X 0xFFFF, 0xF70F, 0xD801, 0xFFC0,
  425. X 0xFFFF, 0xFE00, 0x0000, 0xFFC0,
  426. X 0xBFFF, 0xFE50, 0x415C, 0xFFC0,
  427. X 0xBFFF, 0xFFFC, 0x90FF, 0xFFC0,
  428. X 0xFFFF, 0xFFFD, 0xFEFF, 0xFFC0,
  429. X 0xFFFF, 0xFFFF, 0xFFFF, 0xFFC0,
  430. X/**/
  431. X 0x01E0, 0xE1F0, 0xFC03, 0xFE00,
  432. X 0x41E1, 0xC78F, 0xC03F, 0xF800,
  433. X 0x61C7, 0x2BDD, 0xE1FF, 0x0000,
  434. X 0x4394, 0x7FFF, 0xFD80, 0x0000,
  435. X 0x4C57, 0xFFBF, 0x7FFD, 0xFFC0,
  436. X 0x1FBB, 0xFFFF, 0xBFB4, 0x3FC0,
  437. X 0x6FF0, 0xFCCF, 0xFFFC, 0xC1C0,
  438. X 0x65F3, 0xF9C4, 0xB7FF, 0x9C00,
  439. X 0x79FF, 0x8F33, 0x6BBD, 0xFB00,
  440. X 0x70E7, 0xF136, 0x667F, 0xF9C0,
  441. X 0x4FE0, 0x19D4, 0x0D3F, 0xD8C0,
  442. X 0x4E9F, 0xC9FF, 0xC3EE, 0x3440,
  443. X 0x6580, 0x67D7, 0xECBF, 0xFB00,
  444. X 0x7A3E, 0x2FBF, 0x9EFF, 0xFF80,
  445. X 0x69FF, 0xCF2A, 0xA3FF, 0xF580,
  446. X 0x6700, 0x67E6, 0xC7FD, 0xB1C0,
  447. X 0x583F, 0x1AF4, 0xA7FF, 0xF3C0,
  448. X 0x31FF, 0xF5FF, 0xFFFF, 0x73C0,
  449. X 0x53E0, 0x1DAF, 0xFEA7, 0x23C0,
  450. X 0x4700, 0x00E7, 0xEF58, 0xE1C0,
  451. X 0x4E07, 0xFFE3, 0x77E3, 0xC1C0,
  452. X 0x383F, 0xFC00, 0x078F, 0x81C0,
  453. X/**/
  454. X };
  455. X
  456. Xstruct Image Mandimage1 = {
  457. X 0,  /* LeftEdge */
  458. X 0,  /* TopEdge */
  459. X 58,  /* Width */
  460. X 22,  /* Height */
  461. X 2,  /* Depth */
  462. X (USHORT *)MandimageData1,  /* ImageData */
  463. X 0xFF,  /* PlanePick */
  464. X 0x0,  /* PlaneOnOff */
  465. X 0,  /* [NextImage] */
  466. X };
  467. X
  468. Xstruct DiskObject MandIcon = {
  469. X WB_DISKMAGIC,   /* do_Magic */
  470. X WB_DISKVERSION, /* do_Version */
  471. X
  472. X/* Embedded Gadget Structure */
  473. X 0,  /* [NextGadget] */
  474. X 23,  /* LeftEdge */
  475. X 14,  /* TopEdge */
  476. X 58,  /* Width */
  477. X 23,  /* Height */
  478. X 0x5,  /* Flags */
  479. X 0x3,  /* Activation */
  480. X 0x1,  /* GadgetType */
  481. X (APTR)&Mandimage1, /* GadgetRender */
  482. X NULL,     /* SelectRender */
  483. X NULL,     /* GadgetText */
  484. X 0x0,  /* MutualExclude */
  485. X 0x0,  /* [SpecialInfo] */
  486. X 0,  /* GadgetID */
  487. X 0x0,  /* [UserData] */
  488. X
  489. X/* Rest of DiskObject structure */
  490. X 0x4,  /* do_Type */
  491. X "MandelBrot:MandelVroom",   /* do_Default Tool */
  492. X 0x0,  /* [do_ToolTypes] */
  493. X 0x80000000,  /* do_CurrentX */
  494. X 0x80000000,  /* do_CurrentY */
  495. X 0x0,  /* [do_DrawerData] */
  496. X 0x0,  /* [do_ToolWindow] */
  497. X 10240 /* do_StackSize */
  498. X };
  499. X
  500. XUSHORT  JuliaimageData1[] = {
  501. X 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  502. X 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  503. X 0x0000, 0x0000, 0x0F80, 0x0000, 0x0000,
  504. X 0x0000, 0x0000, 0x7F60, 0x0000, 0x0000,
  505. X 0x0000, 0x000F, 0xF07E, 0x0000, 0x0000,
  506. X 0x0000, 0x0079, 0xC071, 0xC000, 0x0000,
  507. X 0x0004, 0xFFDB, 0xFFFE, 0xFC00, 0x0000,
  508. X 0x001C, 0x6FDF, 0xFFFF, 0xFF7D, 0x0000,
  509. X 0x00FF, 0xF183, 0xFFE0, 0x73C3, 0xC000,
  510. X 0x05FF, 0xF100, 0x7FE0, 0xC3FF, 0xFC00,
  511. X 0x33C3, 0xFC00, 0x7FFE, 0x007C, 0x6D80,
  512. X 0x1F85, 0xF800, 0xFFF8, 0x007F, 0x0670,
  513. X 0x03F1, 0xFC06, 0x3FF0, 0x01FE, 0x03E0,
  514. X 0x003B, 0xFF98, 0x0FF0, 0x021F, 0xDF80,
  515. X 0x000F, 0x187C, 0x3FFF, 0xE6FE, 0xB000,
  516. X 0x0003, 0xFFFD, 0xFFFF, 0xDFC1, 0xC000,
  517. X 0x0000, 0x003E, 0x7FDF, 0x7FFF, 0x0000,
  518. X 0x0000, 0x0006, 0x785B, 0x6000, 0x0000,
  519. X 0x0000, 0x0000, 0xFC7E, 0x0000, 0x0000,
  520. X 0x0000, 0x0000, 0x1BF0, 0x0000, 0x0000,
  521. X 0x0000, 0x0000, 0x0380, 0x0000, 0x0000,
  522. X 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  523. X/**/
  524. X 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  525. X 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  526. X 0x0000, 0x0000, 0x0D80, 0x0000, 0x0000,
  527. X 0x0000, 0x0000, 0x70E0, 0x0000, 0x0000,
  528. X 0x0000, 0x000F, 0xFFFE, 0x0000, 0x0000,
  529. X 0x0000, 0x007E, 0x3F8F, 0xC000, 0x0000,
  530. X 0x0007, 0xFFF4, 0x0001, 0xFC00, 0x0000,
  531. X 0x001F, 0x93E0, 0x0000, 0xFFF3, 0x0000,
  532. X 0x00F0, 0x0FFC, 0x001F, 0xFC3D, 0xC000,
  533. X 0x0660, 0x0FFF, 0x801F, 0xFC00, 0x7C00,
  534. X 0x2C7C, 0x1FFF, 0x9FFF, 0xFF83, 0xF380,
  535. X 0x1C7E, 0x07FF, 0xFFFF, 0xFF83, 0xF990,
  536. X 0x03FE, 0x03FF, 0xFF8F, 0xFFC1, 0xFC60,
  537. X 0x003C, 0x007F, 0xF00F, 0xFFE0, 0x3F80,
  538. X 0x000F, 0xE7FB, 0xC000, 0x1F03, 0x7000,
  539. X 0x0002, 0xFFFE, 0x0000, 0x3FFE, 0xC000,
  540. X 0x0000, 0x003F, 0x80A1, 0xFFFF, 0x0000,
  541. X 0x0000, 0x0007, 0xC7E6, 0xE000, 0x0000,
  542. X 0x0000, 0x0000, 0xFFBE, 0x0000, 0x0000,
  543. X 0x0000, 0x0000, 0x1C70, 0x0000, 0x0000,
  544. X 0x0000, 0x0000, 0x0280, 0x0000, 0x0000,
  545. X 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
  546. X/**/
  547. X };
  548. X
  549. Xstruct Image Juliaimage1 = {
  550. X 0,  /* LeftEdge */
  551. X 0,  /* TopEdge */
  552. X 78,  /* Width */
  553. X 22,  /* Height */
  554. X 2,  /* Depth */
  555. X (USHORT *)JuliaimageData1,  /* ImageData */
  556. X 0xFF,  /* PlanePick */
  557. X 0x0,  /* PlaneOnOff */
  558. X 0,  /* [NextImage] */
  559. X };
  560. X
  561. Xstruct DiskObject JuliaIcon = {
  562. X WB_DISKMAGIC,   /* do_Magic */
  563. X WB_DISKVERSION, /* do_Version */
  564. X
  565. X/* Embedded Gadget Structure */
  566. X 0,  /* [NextGadget] */
  567. X 23,  /* LeftEdge */
  568. X 14,  /* TopEdge */
  569. X 78,  /* Width */
  570. X 23,  /* Height */
  571. X 0x5,  /* Flags */
  572. X 0x3,  /* Activation */
  573. X 0x1,  /* GadgetType */
  574. X (APTR)&Juliaimage1, /* GadgetRender */
  575. X NULL,     /* SelectRender */
  576. X NULL,     /* GadgetText */
  577. X 0x0,  /* MutualExclude */
  578. X 0x0,  /* [SpecialInfo] */
  579. X 0,  /* GadgetID */
  580. X 0x0,  /* [UserData] */
  581. X
  582. X/* Rest of DiskObject structure */
  583. X 0x4,  /* do_Type */
  584. X "MandelBrot:MandelVroom",   /* do_Default Tool */
  585. X 0x0,  /* [do_ToolTypes] */
  586. X 0x80000000,  /* do_CurrentX */
  587. X 0x80000000,  /* do_CurrentY */
  588. X 0x0,  /* [do_DrawerData] */
  589. X 0x0,  /* [do_ToolWindow] */
  590. X 10240 /* do_StackSize */
  591. X };
  592. X
  593. X/*
  594. X * Save all the data needed to restore the system to current state.
  595. X */
  596. Xint
  597. XSaveCounts(SaveName, Pict)
  598. X  register char *SaveName;
  599. X  register struct Picture *Pict;
  600. X{
  601. X  register FILE  *SaveFile;
  602. X
  603. X  USHORT ViewModes;
  604. X  UBYTE  Depth;
  605. X  ULONG  Version = VERSION;
  606. X  char   ErrMsg[80];
  607. X
  608. X  /*
  609. X   * Change the mouse pointer to Sleepy pointer
  610. X   */
  611. X  SetSleepyPointer();
  612. X
  613. X  /*
  614. X   * open the desired file for writing
  615. X   */
  616. X  SaveFile = fopen(SaveName,"w");
  617. X
  618. X  if (SaveFile == (FILE *) NULL) {
  619. X    sprintf(ErrMsg, "Can't open file %s", SaveName);
  620. X    DispErrMsg(ErrMsg, 0);
  621. X    return(UNSUCCESSFUL);
  622. X  }
  623. X
  624. X  Pict->LeftEdge = Pict->Window->LeftEdge;
  625. X  Pict->TopEdge  = Pict->Window->TopEdge;
  626. X
  627. X  /*
  628. X   * if there is data to save, save it
  629. X   */
  630. X  if (Pict->Counts && ! (Pict->Flags & NO_RAM_GENERATE) ) {
  631. X
  632. X    if (Pict->pNode.ln_Type == MANDPICT) {
  633. X
  634. X      /*
  635. X       * Put out the file header
  636. X       */
  637. X      fwrite((char *) "MAN4",    4,  1, SaveFile);
  638. X    } else {
  639. X
  640. X      /*
  641. X       * Put out the file header
  642. X       */
  643. X      fwrite((char *) "JUL4",    4,  1, SaveFile);
  644. X    }
  645. X
  646. X    /*
  647. X     * Put out the revision number
  648. X     */
  649. X    fwrite((char *) Version,   sizeof(Version), 1, SaveFile);
  650. X
  651. X    if (Pict->pNode.ln_Type == JULIAPICT) {
  652. X
  653. X      /*
  654. X       * Put out the Julia point
  655. X       */
  656. X      fwrite((char *) &Pict->Real,   sizeof(double),   1, SaveFile);
  657. X      fwrite((char *) &Pict->Imag,   sizeof(double),   1, SaveFile);
  658. X    }
  659. X
  660. X    /*
  661. X     * Put out the location on the complex plane
  662. X     */
  663. X    fwrite((char *) &Pict->RealLow,   sizeof(double),   1, SaveFile);
  664. X    fwrite((char *) &Pict->ImagLow,   sizeof(double),   1, SaveFile);
  665. X    fwrite((char *) &Pict->RealHigh,  sizeof(double),   1, SaveFile);
  666. X    fwrite((char *) &Pict->ImagHigh,  sizeof(double),   1, SaveFile);
  667. X
  668. X    /*
  669. X     * Put out the Maximum iteration count for a given point
  670. X     */
  671. X    fwrite((char *) &Pict->MaxIteration, sizeof(SHORT),    1, SaveFile);
  672. X
  673. X    /*
  674. X     * Put out the generator type
  675. X     */
  676. X    fwrite((char *) &Pict->MathMode, sizeof(Pict->MathMode), 1, SaveFile);
  677. X
  678. X    /*
  679. X     * Put out the time it took to generate
  680. X     */
  681. X    fwrite((char *) &CalcTime, sizeof(CalcTime), 1, SaveFile);
  682. X
  683. X    /*
  684. X     * Put out the screen's viewmodes
  685. X     */
  686. X    ViewModes = NewScreen.ViewModes;
  687. X    fwrite((char *) &ViewModes, sizeof(ViewModes), 1, SaveFile);
  688. X
  689. X    /*
  690. X     * Put out the number of bit planes
  691. X     */
  692. X    Depth = NewScreen.Depth;
  693. X    fwrite((char *) &Depth, sizeof(Depth), 1, SaveFile);
  694. X
  695. X    /*
  696. X     * Put some window flags
  697. X     */
  698. X    fwrite((char *) &BorderType, sizeof(BorderType), 1, SaveFile);
  699. X
  700. X    /*
  701. X     * Save the Color Palette
  702. X     */
  703. X    fwrite((char *) &Pict->RGBs, sizeof(Pict->RGBs), 1, SaveFile);
  704. X
  705. X    /*
  706. X     * Save the number of contours
  707. X     */
  708. X    fwrite((char *) &NumContours, sizeof(NumContours), 1, SaveFile);
  709. X
  710. X    /*
  711. X     * Save the contour's heights
  712. X     */
  713. X    fwrite((char *) Pict->Heights, sizeof(SHORT), (int) NumContours, SaveFile);
  714. X
  715. X    /*
  716. X     * Save the contour's pen numbers (Color is a misnomer)
  717. X     */
  718. X    fwrite((char *) Pict->Pens, sizeof(UBYTE), (int) NumContours, SaveFile);
  719. X
  720. X    /*
  721. X     * Put out the image dimensions
  722. X     */
  723. X    fwrite((char *) &Pict->CountX,   sizeof(SHORT),   1, SaveFile);
  724. X    fwrite((char *) &Pict->CountY,   sizeof(SHORT),   1, SaveFile);
  725. X
  726. X    /*
  727. X     * Put out project's position
  728. X     */
  729. X    fwrite((char *) &Pict->LeftEdge, sizeof(Pict->LeftEdge), 1, SaveFile);
  730. X    fwrite((char *) &Pict->TopEdge,  sizeof(Pict->TopEdge),  1, SaveFile);
  731. X    fwrite((char *) &Pict->CurLine,  sizeof(Pict->CurLine),  1, SaveFile);
  732. X
  733. X    (void) WriteRLLTwo( SaveFile, Pict );
  734. X
  735. X  } else {
  736. X    DispErrMsg("No Picture to save",0);
  737. X    fclose(SaveFile);
  738. X    return(UNSUCCESSFUL);
  739. X  }
  740. X
  741. X  fclose(SaveFile);
  742. X
  743. X  if (FromWB) {
  744. X
  745. X    FILE *IconFile;
  746. X    char IconName[80];
  747. X
  748. X    strcpy( IconName, SaveName );
  749. X    strcat( IconName, ".info" );
  750. X
  751. X    if ((IconFile = fopen( IconName, "r" )) == NULL) {
  752. X
  753. X      /*
  754. X       * OutPut an icon for the saved picture
  755. X       */
  756. X      if (Pict->pNode.ln_Type == MANDPICT)
  757. X        (void) PutDiskObject(SaveName,&MandIcon);
  758. X      else
  759. X        (void) PutDiskObject(SaveName,&JuliaIcon);
  760. X
  761. X    } else {
  762. X      fclose( IconFile );
  763. X    }
  764. X  }
  765. X
  766. X  return(SUCCESSFUL);
  767. X} /* SaveCounts */
  768. X
  769. Xint
  770. XWriteRLLTwo( SaveFile, Pict )
  771. X  register FILE *SaveFile;
  772. X  register struct Picture *Pict;
  773. X{
  774. X
  775. X  LONG Words;
  776. X
  777. X  Words = Compress( Pict );
  778. X
  779. X  fwrite( (char *) &Words, sizeof(LONG), 1, SaveFile);
  780. X
  781. X  /* in case I ever recompile into 16 bit ints */
  782. X
  783. X  if (sizeof(int) == 2 && sizeof(int)*Words > 65535) {
  784. X    DispErrMsg("Programming error in Savemand\n", 0);
  785. X    return(UNSUCCESSFUL);
  786. X  }
  787. X
  788. X  fwrite( (char *) Pict->Counts, (int) (sizeof(SHORT) * Words), 1, SaveFile);
  789. X
  790. X  Decompress( Words, Pict );
  791. X  return( SUCCESSFUL );
  792. X}
  793. X
  794. X/* Compress the data.  Count up how many words in a row have the same value.
  795. X * If the count is only one, then just put the data in the compressed array.
  796. X * Otherwise, turn on the most significant bit in the Count, and put it
  797. X * in the compressed array, then put the potential in the array.
  798. X *
  799. X * Advantages:
  800. X * -  Compressed data guaranteed to be as small or smaller than uncompressed
  801. X *    data.
  802. X * -  Compression can be done in place in memory, so it is fast without
  803. X *    requiring extra memory.
  804. X * -  Once compressed, the data can be written to disk with one fwrite,
  805. X *    therefore it should be quicker than previously used method that
  806. X *    compressed and wrote to disk at the same time.
  807. X * -  Maximum iteration count for Mandelbrot potential is 32767. The
  808. X *    previous method only allowed 1023.
  809. X */
  810. Xint
  811. XCompress( Pict )
  812. X  register struct Picture *Pict;
  813. X{
  814. X  register SHORT *CountPtr,*CompressPtr;
  815. X  register SHORT  Count;
  816. X  register USHORT Cur;
  817. X  register ULONG  i;
  818. X  register ULONG  Word = 0;
  819. X
  820. X  i = Pict->CountsSize/sizeof(SHORT);
  821. X
  822. X  CountPtr = CompressPtr = Pict->Counts;
  823. X  Cur = *CountPtr;
  824. X  Count = 1;
  825. X
  826. X  while (--i) {
  827. X    CountPtr++;
  828. X
  829. X    /*
  830. X     * Count up how many in a row have same height
  831. X     */
  832. X    if (Cur == *CountPtr) {
  833. X      Count++;
  834. X    } else {
  835. X      if ( Count > 1 ) {
  836. X        *CompressPtr++ = Count | 0x8000;
  837. X      }
  838. X      *CompressPtr++ = Cur;
  839. X      Count = 1;
  840. X      Cur = *CountPtr;
  841. X    }
  842. X  }
  843. X
  844. X  if ( Count > 1 ) {
  845. X    *CompressPtr++ = Count | 0x8000;
  846. X  }
  847. X  *CompressPtr++ = Cur;
  848. X
  849. X  Word = CompressPtr - Pict->Counts;
  850. X
  851. X  return( Word );
  852. X}
  853. X
  854. X/*
  855. X * Load the state of the program from file
  856. X */
  857. Xint
  858. XLoadCounts(LoadName, Pict )
  859. X  register char *LoadName;
  860. X  register struct Picture *Pict;
  861. X{
  862. X  register FILE  *LoadFile;
  863. X  USHORT ViewModes;
  864. X  UBYTE  Depth;
  865. X  char   Header[5];
  866. X  ULONG  Version;
  867. X  char   ErrMsg[80];
  868. X  int    rc;
  869. X  char  *File, *ExtractName();
  870. X
  871. X  extern int Num_vp_Colors;
  872. X  extern USHORT NewViewModes;
  873. X  extern UBYTE  NewDepth;
  874. X
  875. X  extern struct MathTransBase *MathTransBase;
  876. X  extern LONG   SPTIEEE;
  877. X
  878. X  /*
  879. X   * Change the mouse pointer to Sleepy pointer
  880. X   */
  881. X
  882. X  SetSleepyPointer();
  883. X
  884. X  LoadFile = fopen(LoadName,"r");
  885. X
  886. X  Pict->GenState = FINISHEDSTATE;
  887. X
  888. X  if (LoadFile == (FILE *) NULL) {
  889. X
  890. X    /*
  891. X     * can't read a non-existant file
  892. X     */
  893. X    sprintf(ErrMsg, "File %s not found", LoadName);
  894. X    DispErrMsg(ErrMsg, 0);
  895. X    return( UNSUCCESSFUL );
  896. X  }
  897. X
  898. X  /*
  899. X   * Read and check the file header
  900. X   */
  901. X  (void) fread((char *) &Header[0], 4, 1, LoadFile);
  902. X  Header[4] = '\0';
  903. X
  904. X  if (strcmp(&Header[0], "MAND") != 0 &&
  905. X      strcmp(&Header[0], "MAN1") != 0 &&
  906. X      strcmp(&Header[0], "MAN2") != 0 &&
  907. X      strcmp(&Header[0], "MAN3") != 0 &&
  908. X      strcmp(&Header[0], "MAN4") != 0 &&
  909. X      strcmp(&Header[0], "JUL3") != 0 &&
  910. X      strcmp(&Header[0], "JUL4") != 0    ) {
  911. X
  912. X    /*
  913. X     * File of improper format
  914. X     */
  915. X    sprintf(ErrMsg, "File %s is not a MAND file",LoadName);
  916. X    DispErrMsg(ErrMsg, 0);
  917. X    fclose(LoadFile);
  918. X    return( UNSUCCESSFUL );
  919. X  }
  920. X
  921. X  /*
  922. X   * Read in the version
  923. X   */
  924. X  (void) fread((char *) &Version, sizeof(Version), 1, LoadFile);
  925. X
  926. X  if ( strcmp( &Header[0], "MAN2") == 0 ||
  927. X       strcmp( &Header[0], "MAN3") == 0 ||
  928. X       strcmp( &Header[0], "MAN4") == 0 ||
  929. X       strcmp( &Header[0], "JUL3") == 0 ||
  930. X       strcmp( &Header[0], "JUL4") == 0 ) {
  931. X
  932. X    if ( strcmp( &Header[0], "JUL3") == 0 ||
  933. X         strcmp( &Header[0], "JUL4") == 0 ) {
  934. X
  935. X      Pict->pNode.ln_Type = JULIAPICT;
  936. X      (void) fread((char *) &Pict->Real, sizeof(double), 1, LoadFile);
  937. X      (void) fread((char *) &Pict->Imag, sizeof(double), 1, LoadFile);
  938. X    } else {
  939. X      Pict->pNode.ln_Type = MANDPICT;
  940. X    }
  941. X
  942. X    /*
  943. X     * Read in the location in the complex plane
  944. X     */
  945. X    (void) fread((char *) &Pict->RealLow,  sizeof(double), 1, LoadFile);
  946. X    (void) fread((char *) &Pict->ImagLow,  sizeof(double), 1, LoadFile);
  947. X    (void) fread((char *) &Pict->RealHigh, sizeof(double), 1, LoadFile);
  948. X    (void) fread((char *) &Pict->ImagHigh, sizeof(double), 1, LoadFile);
  949. X  } else {
  950. X
  951. X    /* Must be old FFP code */
  952. X
  953. X    LONG startx, starty, endx, endy;
  954. X
  955. X    LONG SPTieee();
  956. X
  957. X    /*
  958. X     * Read in the FFP form of location in the complex plane
  959. X     */
  960. X    (void) fread((char *) &startx, sizeof(LONG), 1, LoadFile);
  961. X    (void) fread((char *) &starty, sizeof(LONG), 1, LoadFile);
  962. X    (void) fread((char *) &endx,   sizeof(LONG), 1, LoadFile);
  963. X    (void) fread((char *) &endy,   sizeof(LONG), 1, LoadFile);
  964. X
  965. X    /*
  966. X     * Convert it to IEEE format
  967. X     */
  968. X    if (OpenFFPLibs() != 0)
  969. X      return(UNSUCCESSFUL);
  970. X
  971. X    startx = SPTieee( startx );
  972. X    starty = SPTieee( starty );
  973. X    endx   = SPTieee( endx );
  974. X    endy   = SPTieee( endy );
  975. X
  976. X    /*
  977. X     * promote them to doubles
  978. X     */
  979. X    Pict->RealLow  = (double) *( (float *) &startx );
  980. X    Pict->ImagLow  = (double) *( (float *) &starty );
  981. X    Pict->RealHigh = (double) *( (float *) &endx );
  982. X    Pict->ImagHigh = (double) *( (float *) &endy );
  983. X  }
  984. X
  985. X  /*
  986. X   * Read in the maximum iteration count for a given point
  987. X   */
  988. X  (void) fread((char *) &Pict->MaxIteration, sizeof(SHORT), 1, LoadFile);
  989. X
  990. X  /*
  991. X   * Read in the generator type
  992. X   */
  993. X  (void) fread((char *) &Pict->MathMode, sizeof(Pict->MathMode), 1, LoadFile);
  994. X
  995. X  /*
  996. X   * Read in the calculation time
  997. X   */
  998. X  (void) fread((char *) &CalcTime, sizeof(CalcTime), 1, LoadFile);
  999. X
  1000. X  /*
  1001. X   * Read in the screen's viewmodes
  1002. X   */
  1003. X  (void) fread((char *) &ViewModes, sizeof(ViewModes), 1, LoadFile);
  1004. X
  1005. X  ViewModes &= HIRES | INTERLACE | EXTRA_HALFBRITE;
  1006. X  Pict->ViewModes = ViewModes;
  1007. X
  1008. X  /*
  1009. X   * Read in the number of bit planes
  1010. X   */
  1011. X  (void) fread((char *) &Depth, sizeof(Depth), 1, LoadFile);
  1012. X  Pict->Depth = Depth;
  1013. X
  1014. X  /*
  1015. X   * Read in the window flags
  1016. X   */
  1017. X  (void) fread((char *) &BorderType, sizeof(BorderType), 1, LoadFile);
  1018. X
  1019. X  /*
  1020. X   * Read in the color palette information
  1021. X   */
  1022. X  (void) fread((char *) &Pict->RGBs[0], sizeof(Pict->RGBs), 1, LoadFile);
  1023. X
  1024. X  /*
  1025. X   * Read in the number of contours
  1026. X   */
  1027. X  (void) fread((char *) &NumContours, sizeof(NumContours), 1, LoadFile);
  1028. X
  1029. X  /*
  1030. X   * Read in the heights
  1031. X   */
  1032. X  (void) fread((char *) Pict->Heights, sizeof(SHORT), NumContours, LoadFile);
  1033. X
  1034. X  /*
  1035. X   * Read in the pen numbers (Color is a misnomer)
  1036. X   */
  1037. X  (void) fread((char *) Pict->Pens, sizeof(UBYTE), NumContours, LoadFile);
  1038. X
  1039. X  for ( ; NumContours < NUMCONTS; NumContours++ ) {
  1040. X    *(Pict->Heights + NumContours) = 0;
  1041. X    *(Pict->Pens + NumContours) = 0;
  1042. X  }
  1043. X
  1044. X  /*
  1045. X   * Read in the image dimensions
  1046. X   */
  1047. X  (void) fread((char *) &Pict->CountX,   sizeof(SHORT),  1, LoadFile);
  1048. X  (void) fread((char *) &Pict->CountY,   sizeof(SHORT),  1, LoadFile);
  1049. X
  1050. X  if ( strcmp( &Header[0], "MAN4") == 0 ||
  1051. X       strcmp( &Header[0], "JUL4") == 0 ) {
  1052. X
  1053. X    /*
  1054. X     * Read in the image dimensions
  1055. X     */
  1056. X    (void) fread((char *) &Pict->LeftEdge, sizeof(Pict->LeftEdge),
  1057. X                                           1, LoadFile);
  1058. X    (void) fread((char *) &Pict->TopEdge,  sizeof(Pict->TopEdge),
  1059. X                                           1, LoadFile);
  1060. X    (void) fread((char *) &Pict->CurLine,  sizeof(Pict->CurLine),
  1061. X                                           1, LoadFile);
  1062. X    if (Pict->CurLine > Pict->CountY)
  1063. X      Pict->CurLine -= TOPMARG;
  1064. X
  1065. X  } else {
  1066. X    Pict->CurLine = Pict->CountY;
  1067. X  }
  1068. X
  1069. X  GetCountsMemory( Pict );
  1070. X
  1071. X  if (Pict->Counts == (SHORT *) NULL || (Pict->Flags & NO_RAM_GENERATE)) {
  1072. X    DispErrMsg("Can't load counts. Out of RAM!!",0);
  1073. X    fclose(LoadFile);
  1074. X    return( UNSUCCESSFUL );
  1075. X  }
  1076. X
  1077. X  if ( strcmp( &Header[0], "MAN3") == 0 ||
  1078. X       strcmp( &Header[0], "MAN4") == 0 ||
  1079. X       strcmp( &Header[0], "JUL3") == 0 ||
  1080. X       strcmp( &Header[0], "JUL4") == 0 ) {
  1081. X
  1082. X    rc = ReadRLLTwo( LoadFile, Pict );
  1083. X  } else {
  1084. X    rc = ReadRLLOne( LoadFile, Pict );
  1085. X  }
  1086. X  fclose(LoadFile);
  1087. X
  1088. X  if (rc != SUCCESSFUL) {
  1089. X    return( rc );
  1090. X  }
  1091. X
  1092. X  File = ExtractName( LoadName );
  1093. X  strncpy( Pict->Title, "  ", 2);
  1094. X  strncat( Pict->Title, File, sizeof(Pict->Title)-3);
  1095. X
  1096. X  CalculateGaps( Pict );
  1097. X
  1098. X  NewViewModes = Pict->ViewModes;
  1099. X  NewDepth     = Pict->Depth;
  1100. X
  1101. X  if ( MaybeNewScreen() == 0 ) {
  1102. X
  1103. X    /*
  1104. X     * Let's show it to them
  1105. X     */
  1106. X    if (OpenPicture( Pict ) != 0) {
  1107. X
  1108. X      return( UNSUCCESSFUL );
  1109. X
  1110. X    } else {
  1111. X      LoadRGB4( vp, Pict->RGBs, Num_vp_Colors );
  1112. X      ReColor( Pict );
  1113. X    }
  1114. X  }
  1115. X
  1116. X  GetCurPict();
  1117. X
  1118. X  if (CurPict) {
  1119. X    LoadRGB4( vp, CurPict->RGBs, Num_vp_Colors );
  1120. X  }
  1121. X  InitBorderSubs();
  1122. X
  1123. X  return( SUCCESSFUL );
  1124. X} /* LoadCounts */
  1125. X
  1126. X/* Load count information in pseudo RLL format */
  1127. X/* Bits 9-0 are iteration count.               */
  1128. X/* Bits 15-10 are how many iteration count of same height in a row */
  1129. X
  1130. Xint
  1131. XReadRLLOne( LoadFile, Pict )
  1132. X  register FILE *LoadFile;
  1133. X  register struct Picture *Pict;
  1134. X{
  1135. X  register SHORT *CountPtr;
  1136. X  register LONG   i;
  1137. X  register ULONG  Count = 0;
  1138. X
  1139. X  USHORT t;
  1140. X
  1141. X  CountPtr = Pict->Counts;
  1142. X
  1143. X  i = Pict->CountsSize / sizeof( SHORT );
  1144. X
  1145. X  while (i > 0) {
  1146. X    if ( fread((char *) &t, sizeof(t), 1, LoadFile) == 0) {
  1147. X      DispErrMsg("Premature EOF on source file",0);
  1148. X      fclose(LoadFile);
  1149. X      return( UNSUCCESSFUL);
  1150. X    }
  1151. X    Count = t >> 10;
  1152. X    t = t & 0x3ff;
  1153. X
  1154. X    for (; Count > 0; Count--) {
  1155. X     *(CountPtr++) = t;
  1156. X      i--;
  1157. X    }
  1158. X  }
  1159. X  return( SUCCESSFUL );
  1160. X}
  1161. X
  1162. Xint
  1163. XReadRLLTwo( LoadFile, Pict )
  1164. X  register FILE *LoadFile;
  1165. X  register struct Picture *Pict;
  1166. X{
  1167. X  LONG Words;
  1168. X
  1169. X  if (fread((char *) &Words, sizeof(Words), 1, LoadFile) == 0) {
  1170. X    DispErrMsg("Premature EOF on source file",0);
  1171. X    fclose(LoadFile);
  1172. X    return(UNSUCCESSFUL);
  1173. X  }
  1174. X  if (fread((char *) Pict->Counts,(int)(sizeof(SHORT)*Words),1,LoadFile) == 0){
  1175. X    DispErrMsg("Premature EOF on source file",0);
  1176. X    fclose(LoadFile);
  1177. X    return(UNSUCCESSFUL);
  1178. X  }
  1179. X  Decompress( Words, Pict );
  1180. X  return( SUCCESSFUL );
  1181. X}
  1182. X
  1183. X/* This algorithm decompresses the data.  The data array has
  1184. X * been malloced large enough to hold the decompressed data.  The data
  1185. X * is read from the disk into the array in compressed format.  This
  1186. X * decompresses the data in place.  The data must be decompressed from the
  1187. X * back to the front.
  1188. X */
  1189. XDecompress( Word, Pict )
  1190. X  LONG  Word;
  1191. X  struct Picture *Pict;
  1192. X{
  1193. X  register SHORT *CountPtr, *CompressPtr;
  1194. X  register SHORT  Count,Cur;
  1195. X  register LONG   i;
  1196. X  register SHORT  j;
  1197. X
  1198. X  /* Point to the last word of compressed data */
  1199. X
  1200. X  CompressPtr = Pict->Counts + Word - 1;
  1201. X
  1202. X  i = Pict->CountsSize/sizeof(SHORT);
  1203. X
  1204. X  /* Point to the last word of uncompressed data */
  1205. X
  1206. X  CountPtr = Pict->Counts + i - 1;
  1207. X
  1208. X  /* While there is data to uncompress.... */
  1209. X
  1210. X  while (i > 1 && CountPtr >= Pict->Counts && CompressPtr >= Pict->Counts) {
  1211. X
  1212. X    /* Pick up the last two words */
  1213. X
  1214. X    Cur   = *CompressPtr--;
  1215. X    Count = *CompressPtr;
  1216. X
  1217. X    if (Count & 0x8000) {        /* is it compressed? */
  1218. X
  1219. X      Count &= 0x7fff;           /* extract count */
  1220. X
  1221. X      for ( j = 0; j < Count; j++) {  /* Decompress it */
  1222. X        *CountPtr-- = Cur;
  1223. X        i--;
  1224. X      }
  1225. X      CompressPtr--;
  1226. X
  1227. X    } else {
  1228. X
  1229. X      *CountPtr-- = Cur;         /* just move it */
  1230. X      i--;
  1231. X    }
  1232. X  }
  1233. X}
  1234. SHAR_EOF
  1235. echo "extracting scroll.c"
  1236. sed 's/^X//' << \SHAR_EOF > scroll.c
  1237. X/*
  1238. X * MandelVroom 2.0
  1239. X *
  1240. X * (c) Copyright 1987,1989  Kevin L. Clague, San Jose, CA
  1241. X *
  1242. X * All rights reserved.
  1243. X *
  1244. X * Permission is hereby granted to distribute this program's source
  1245. X * executable, and documentation for non-comercial purposes, so long as the
  1246. X * copyright notices are not removed from the sources, executable or
  1247. X * documentation.  This program may not be distributed for a profit without
  1248. X * the express written consent of the author Kevin L. Clague.
  1249. X *
  1250. X * This program is not in the public domain.
  1251. X *
  1252. X * Fred Fish is expressly granted permission to distribute this program's
  1253. X * source and executable as part of the "Fred Fish freely redistributable
  1254. X * Amiga software library."
  1255. X *
  1256. X * Permission is expressly granted for this program and it's source to be
  1257. X * distributed as part of the Amicus Amiga software disks, and the
  1258. X * First Amiga User Group's Hot Mix disks.
  1259. X *
  1260. X * contents: this file contains the functions used to implement MandelVroom's
  1261. X * pan command.  It seems to have a bug when resizing pictures slightly
  1262. X * smaller.
  1263. X */
  1264. X
  1265. X#include "mandp.h"
  1266. X
  1267. Xstatic int ScrollHotX, ScrollHotY;
  1268. X
  1269. XUBYTE ScrollOn = 1;
  1270. X
  1271. X#ifdef TEMPWINDOW
  1272. X#define SAFEBLIT
  1273. X
  1274. Xstatic struct NewWindow NewTemp = {
  1275. X   0,12,                     /* start position           */
  1276. X   80,80,                    /* width, height            */
  1277. X   (UBYTE) 0, (UBYTE) NORMALPEN,
  1278. X   MOUSEBUTTONS,             /* IDCMP flags              */
  1279. X                             /* MandWind flags           */
  1280. X   WINDOWDRAG | NOCAREREFRESH | SMART_REFRESH,
  1281. X   (struct Gadget *) NULL,   /* first gadget             */
  1282. X   (struct Image *) NULL,    /* user checkmark           */
  1283. X   (UBYTE *) NULL,           /* Title                    */
  1284. X   (struct Screen *) NULL,   /* pointer to screen        */
  1285. X   (struct BitMap *) NULL,   /* pointer to superbitmap   */
  1286. X   20,20,-1,-1,              /* sizing                   */
  1287. X   CUSTOMSCREEN              /* type of screen           */
  1288. X   };
  1289. X
  1290. Xstatic struct Window *TempWind;
  1291. X#endif
  1292. X
  1293. XScrollPictCmd(Msg)
  1294. X  struct IntuiMessage *Msg;
  1295. X{
  1296. X  struct Window *Window;
  1297. X  static struct Picture *Pict;
  1298. X
  1299. X  Window = Msg->IDCMPWindow;
  1300. X  Pict = (struct Picture *) Window->UserData;
  1301. X
  1302. X  switch( Msg->Class ) {
  1303. X    case NEWSIZE:
  1304. X         if (CurPict && (CurPict->Flags & SCROLL_HAPPENED)) {
  1305. X           MoveClipImage(CurPict);
  1306. X         }
  1307. X         break;
  1308. X
  1309. X    case MENUPICK:
  1310. X         switch( SUBNUM(Msg->Code) ) {
  1311. X           case SETSCROLL:
  1312. X                State = SCROLLPICTSTATE;
  1313. X                ThrowTask(CurPict);
  1314. X                if ( ! (CurPict->Flags & SCROLL_HAPPENED)) {
  1315. X
  1316. X                  if ( AllocScrollTemp(CurPict) == UNSUCCESSFUL ) {
  1317. X                    return;
  1318. X                  }
  1319. X                  SaveInitialImage(CurPict);
  1320. X                }
  1321. X                CurPict->Flags |= SCROLL_HAPPENED;
  1322. X                SetToPointer();
  1323. X                break;
  1324. X
  1325. X           case GENSCROLL:
  1326. X                if (CurPict && CurPict->Flags & SCROLL_HAPPENED) {
  1327. X                  Generate(CurPict);
  1328. X                }
  1329. X                break;
  1330. X
  1331. X           case CANCELSCROLL:
  1332. X                ReColor(CurPict);
  1333. X                break;
  1334. X         }
  1335. X         break;
  1336. X
  1337. X    case MOUSEBUTTONS:
  1338. X         switch( Msg->Code ) {
  1339. X
  1340. X           case SELECTDOWN:                   /* start drag */
  1341. X                if (Pict == NULL || Pict != CurPict) {
  1342. X                  return;
  1343. X                }
  1344. X                ScrollHotX = MouseX - CurPict->ImageLoc.Left;
  1345. X                ScrollHotY = MouseY - CurPict->ImageLoc.Top;
  1346. X                Scroll( CurPict);
  1347. X                ModifyIDCMP(Window, Window->IDCMPFlags | MOUSEMOVE);
  1348. X                break;
  1349. X
  1350. X           case SELECTUP:                     /* stop slide */
  1351. X                ModifyIDCMP(Window, Window->IDCMPFlags & ~MOUSEMOVE);
  1352. X                break;
  1353. X         }
  1354. X         break;
  1355. X
  1356. X    case MOUSEMOVE:
  1357. X         Scroll( CurPict);
  1358. X         break;
  1359. X  }
  1360. X}
  1361. X
  1362. XSaveInitialImage(Pict)
  1363. X  struct Picture *Pict;
  1364. X{
  1365. X#ifdef SAFEBLIT
  1366. X  SafeClipBlit(Pict->Window,  Pict->LeftMarg, Pict->TopMarg,
  1367. X               TempWind,      0,            0,
  1368. X                              Pict->CountX, Pict->CountY,
  1369. X                              0xc0, __LINE__);
  1370. X#else
  1371. X  ClipBlit(Pict->Window->RPort, Pict->LeftMarg, Pict->TopMarg,
  1372. X           &Pict->ScrollRp,           0,            0,
  1373. X                                Pict->CountX, Pict->CountY,
  1374. X                                0xc0);
  1375. X#endif
  1376. X}
  1377. X
  1378. XScroll( Pict )
  1379. X  struct Picture *Pict;
  1380. X{
  1381. X  CalcNewLoc(Pict,MouseX,MouseY); /* figure out location of new image */
  1382. X  MoveClipImage(Pict);
  1383. X}
  1384. X
  1385. XCalcNewLoc(Pict, MouseX, MouseY)
  1386. X  register struct Picture *Pict;
  1387. X  int MouseX, MouseY;
  1388. X{
  1389. X  /* set new ImageLoc */
  1390. X
  1391. X  Pict->ImageLoc.Top    = MouseY - ScrollHotY;
  1392. X  Pict->ImageLoc.Left   = MouseX - ScrollHotX;
  1393. X  Pict->ImageLoc.Bot    = Pict->ImageLoc.Top  + Pict->CountY;
  1394. X  Pict->ImageLoc.Right  = Pict->ImageLoc.Left + Pict->CountX;
  1395. X}
  1396. X
  1397. XMoveClipImage(Pict)
  1398. X  register struct Picture  *Pict;
  1399. X{
  1400. X  struct Window   *Window;
  1401. X  struct RastPort *wind_Rp, *tmp_Rp;
  1402. X
  1403. X  register int POLeft, PORight, POTop, POBot;
  1404. X
  1405. X  struct Rect  SaveRect;
  1406. X  struct Rect  DispRect;
  1407. X
  1408. X  Window = Pict->Window;
  1409. X
  1410. X  SaveRect = Pict->ClipImage; /* struct assign */
  1411. X
  1412. X  DispRect.Left  = Pict->LeftMarg;
  1413. X  DispRect.Top   = Pict->TopMarg;
  1414. X  DispRect.Right = Window->Width - Pict->RightMarg - 1;
  1415. X  DispRect.Bot   = Window->Height - Pict->BotMarg - 1;
  1416. X
  1417. X  if (Pict->ImageLoc.Left  > DispRect.Right ||
  1418. X      Pict->ImageLoc.Top   > DispRect.Bot   ||
  1419. X      Pict->ImageLoc.Right < DispRect.Left  ||
  1420. X      Pict->ImageLoc.Bot   < DispRect.Top   ) {
  1421. X
  1422. X    return;
  1423. X  }
  1424. X
  1425. X  if (Pict->ImageLoc.Left < DispRect.Left) {
  1426. X    Pict->ClipImage.Left =  DispRect.Left;
  1427. X    POLeft = -Pict->ImageLoc.Left + Pict->LeftMarg;
  1428. X  } else {
  1429. X    Pict->ClipImage.Left =  Pict->ImageLoc.Left;
  1430. X    POLeft =  0;
  1431. X  }
  1432. X
  1433. X  if (Pict->ImageLoc.Top < DispRect.Top) {
  1434. X    Pict->ClipImage.Top = DispRect.Top;
  1435. X    POTop = -Pict->ImageLoc.Top + Pict->TopMarg;
  1436. X  } else {
  1437. X    Pict->ClipImage.Top = Pict->ImageLoc.Top;
  1438. X    POTop = 0;
  1439. X  }
  1440. X
  1441. X  if (Pict->ImageLoc.Right <= DispRect.Right) {
  1442. X    Pict->ClipImage.Right = Pict->ImageLoc.Right;
  1443. X    PORight = Pict->CountX-1;
  1444. X  } else {
  1445. X    Pict->ClipImage.Right = DispRect.Right;
  1446. X    PORight = DispRect.Right - Pict->ImageLoc.Left;
  1447. X  }
  1448. X
  1449. X  if (Pict->ImageLoc.Bot <= DispRect.Bot) {
  1450. X    Pict->ClipImage.Bot = Pict->ImageLoc.Bot;
  1451. X    POBot = Pict->CountY - 1;
  1452. X  } else {
  1453. X    Pict->ClipImage.Bot = DispRect.Bot;
  1454. X    POBot = DispRect.Bot - Pict->ImageLoc.Top;
  1455. X  }
  1456. X
  1457. X  wind_Rp = Window->RPort;
  1458. X
  1459. X#ifdef TEMPWINDOW
  1460. X  tmp_Rp = TempWind->RPort;
  1461. X#else
  1462. X  tmp_Rp = &Pict->ScrollRp;
  1463. X#endif
  1464. X
  1465. X  if (POLeft < PORight && POTop < POBot) {
  1466. X
  1467. X  /* Now copy temp rastport data to window */
  1468. X
  1469. X#ifdef SAFEBLIT
  1470. X    SafeClipBlit(TempWind, POLeft, POTop, Window,
  1471. X                       Pict->ClipImage.Left, Pict->ClipImage.Top,
  1472. X                       PORight - POLeft + 1, POBot - POTop + 1, 0xc0,
  1473. X                       __LINE__);
  1474. X#else
  1475. X    ClipBlit(tmp_Rp,   POLeft, POTop, wind_Rp,
  1476. X                       Pict->ClipImage.Left, Pict->ClipImage.Top,
  1477. X                       PORight - POLeft + 1, POBot - POTop + 1, 0xc0);
  1478. X#endif
  1479. X
  1480. X#if 0
  1481. X    printf("l %d t %d r %d b %d\n",POLeft, POTop, PORight, POBot);
  1482. X    printf("width %d height %d\n",
  1483. X            PORight - POLeft + 1, POBot - POTop + 1);
  1484. X#endif
  1485. X  }
  1486. X
  1487. X  Pict->DataClip.Left  = POLeft;
  1488. X  Pict->DataClip.Right = PORight;
  1489. X  Pict->DataClip.Top   = POTop;
  1490. X  Pict->DataClip.Bot   = POBot;
  1491. X
  1492. X  /* Undraw the old picture */
  1493. X
  1494. X  SetAPen(wind_Rp, 0);
  1495. X
  1496. X  if (Pict->ClipImage.Left > SaveRect.Left) {
  1497. X
  1498. X    FillCheck(Window, SaveRect.Left, SaveRect.Top,
  1499. X                      Pict->ClipImage.Left, SaveRect.Bot);
  1500. X  } else
  1501. X  if (Pict->ClipImage.Right < SaveRect.Right) {
  1502. X
  1503. X    FillCheck(Window, Pict->ClipImage.Right, Pict->ClipImage.Top,
  1504. X                      SaveRect.Right, SaveRect.Bot);
  1505. X  }
  1506. X
  1507. X  if (Pict->ClipImage.Top > SaveRect.Top) {
  1508. X
  1509. X    FillCheck(Window, SaveRect.Left, SaveRect.Top,
  1510. X                      SaveRect.Right, Pict->ClipImage.Top);
  1511. X  } else
  1512. X  if (Pict->ClipImage.Bot < SaveRect.Bot) {
  1513. X
  1514. X    FillCheck(Window, SaveRect.Left,  Pict->ClipImage.Bot,
  1515. X                      SaveRect.Right, SaveRect.Bot);
  1516. X  }
  1517. X}
  1518. X
  1519. XFillCheck(Window,src_x,src_y,dst_x,dst_y)
  1520. X  struct Window *Window;
  1521. X  int src_x,src_y,dst_x,dst_y;
  1522. X{
  1523. X  if (src_x < 0 || src_x > Window->Width) {
  1524. X#ifdef DEBUG
  1525. X    printf("Bad Fill src_x %d Width %d\n",
  1526. X            src_x,Window->Width);
  1527. X#endif
  1528. X    return;
  1529. X  }
  1530. X
  1531. X  if (src_y < 0 || src_y > Window->Height) {
  1532. X#ifdef DEBUG
  1533. X    printf("Bad Fill src_y %d Height %d\n",
  1534. X            src_y,Window->Height);
  1535. X#endif
  1536. X    return;
  1537. X  }
  1538. X
  1539. X  if (dst_x < 0 || dst_x > Window->Width) {
  1540. X#ifdef DEBUG
  1541. X    printf("Bad Fill dst_x %d Width %d\n",
  1542. X            dst_x,Window->Width);
  1543. X#endif
  1544. X    return;
  1545. X  }
  1546. X
  1547. X  if (dst_y < 0 || dst_y > Window->Height) {
  1548. X#ifdef DEBUG
  1549. X    printf("Bad Fill dst_y %d Height %d\n",
  1550. X            dst_y,Window->Height);
  1551. X#endif
  1552. X    return;
  1553. X  }
  1554. X  if (src_x > dst_x) {
  1555. X#ifdef DEBUG
  1556. X    printf("inverted rect fill\n");
  1557. X#endif
  1558. X    return;
  1559. X  }
  1560. X  if (src_y > dst_y) {
  1561. X#ifdef DEBUG
  1562. X    printf("end for end flipped rect fill\n");
  1563. X#endif
  1564. X    return;
  1565. X  }
  1566. X  RectFill(Window->RPort, src_x,src_y,dst_x,dst_y);
  1567. X}
  1568. X
  1569. XAllocScrollTemp( Pict )
  1570. X  register struct Picture *Pict;
  1571. X{
  1572. X  LONG Plane;
  1573. X  PLANEPTR t;
  1574. X
  1575. X  extern struct MenuItem ScrollSub[];
  1576. X
  1577. X  static ScrollInited;
  1578. X
  1579. X  extern struct NewScreen NewScreen;
  1580. X
  1581. X  if ( !ScrollOn )
  1582. X    return;
  1583. X
  1584. X#ifdef TEMPWINDOW
  1585. X
  1586. X  NewTemp.Width    = Pict->Window->Width;
  1587. X  NewTemp.Height   = Pict->Window->Height;
  1588. X  NewTemp.LeftEdge = NewScreen.Width - NewTemp.Width-2;
  1589. X  NewTemp.TopEdge  = 0;
  1590. X  NewTemp.Screen   = screen;
  1591. X  TempWind         = OpenWindow( &NewTemp );
  1592. X/*WindowToBack( TempWind );*/
  1593. X  return( SUCCESSFUL );
  1594. X
  1595. X#else
  1596. X
  1597. X  if ( Pict->ScrollRp.BitMap == NULL ) {
  1598. X
  1599. X    InitRastPort( &Pict->ScrollRp );
  1600. X    Pict->ScrollRp.BitMap = &Pict->ScrollBitMap;
  1601. X  }
  1602. X
  1603. X  InitBitMap( &Pict->ScrollBitMap, (long) NewScreen.Depth,
  1604. X               Pict->CountX, Pict->CountY);
  1605. X
  1606. X  for (Plane = 0; Plane < NewScreen.Depth; Plane++) {
  1607. X
  1608. X    t = (PLANEPTR) AllocRaster(Pict->CountX, Pict->CountY);
  1609. X    Pict->ScrollBitMap.Planes[Plane] = (PLANEPTR) t;
  1610. X
  1611. X    if (t == NULL) {
  1612. X      FreeScrollTemp( Pict );
  1613. X      return(UNSUCCESSFUL);
  1614. X    }
  1615. X  }
  1616. X  return(SUCCESSFUL);
  1617. X#endif
  1618. X}
  1619. X
  1620. XFreeScrollTemp( Pict )
  1621. X  struct Picture *Pict;
  1622. X{
  1623. X  LONG Plane;
  1624. X
  1625. X  if (Pict->Flags & SCROLL_HAPPENED) {
  1626. X
  1627. X#ifdef TEMPWINDOW
  1628. X    CloseWindow( TempWind );
  1629. X#else
  1630. X
  1631. X    for (Plane = 0; Plane < Pict->ScrollBitMap.Depth; Plane++) {
  1632. X
  1633. X      if (Pict->ScrollBitMap.Planes[Plane]) {
  1634. X
  1635. X        FreeRaster( (char *) Pict->ScrollBitMap.Planes[Plane],
  1636. X                    Pict->CountX,Pict->CountY);
  1637. X        Pict->ScrollBitMap.Planes[Plane] = NULL;
  1638. X      }
  1639. X    }
  1640. X#endif
  1641. X  }
  1642. X  ResetScrollRects(Pict);
  1643. X}
  1644. X
  1645. XResetScrollRects(Pict)
  1646. X  struct Picture *Pict;
  1647. X{
  1648. X  Pict->Flags &= ~SCROLL_HAPPENED;
  1649. X
  1650. X  Pict->ImageLoc.Left   = Pict->LeftMarg;
  1651. X  Pict->ImageLoc.Top    = Pict->TopMarg;
  1652. X  Pict->ImageLoc.Right  = Pict->LeftMarg + Pict->CountX - 1;
  1653. X  Pict->ImageLoc.Bot    = Pict->TopMarg  + Pict->CountY - 1;
  1654. X
  1655. X  Pict->ClipImage = Pict->ImageLoc; /* struct assignment */
  1656. X}
  1657. X
  1658. X#ifdef SAFEBLIT
  1659. Xstatic
  1660. XSafeClipBlit( src_Wind, src_x, src_y,
  1661. X              dst_Wind, dst_x, dst_y,
  1662. X              width, height, min_terms,
  1663. X              line_no )
  1664. X
  1665. X  struct Window *src_Wind, *dst_Wind;
  1666. X  LONG   src_x, src_y, dst_x, dst_y, width, height, min_terms;
  1667. X  LONG   line_no;
  1668. X{
  1669. X
  1670. X  if (src_x < 0 || src_x > src_Wind->Width) {
  1671. X    printf("Line %d Bad blit src_x %d Width %d\n",
  1672. X            line_no,src_x,src_Wind->Width);
  1673. X    return;
  1674. X  }
  1675. X
  1676. X  if (src_y < 0 || src_y > src_Wind->Height) {
  1677. X    printf("Line %d Bad blit src_y %d Height %d\n",
  1678. X            line_no, src_y,src_Wind->Height);
  1679. X    return;
  1680. X  }
  1681. X
  1682. X  if (width < 1 || width > src_Wind->Width) {
  1683. X    printf("Line %d Bad blit width %d\n",line_no, width);
  1684. X    return;
  1685. X  }
  1686. X
  1687. X  if (src_x + width > src_Wind->Width) {
  1688. X    printf("Line %d Blit outside %d Width %d \n",
  1689. X            line_no,src_x+width,src_Wind->Width);
  1690. X    return;
  1691. X  }
  1692. X
  1693. X  if (height < 1 || height > src_Wind->Height) {
  1694. X    printf("Line %d Bad blit height %d\n",line_no,height);
  1695. X    return;
  1696. X  }
  1697. X
  1698. X  if (src_y + height > src_Wind->Height) {
  1699. X    printf("Line %d Blit outside %d Height %d \n",
  1700. X            line_no,src_y+height,src_Wind->Height);
  1701. X    return;
  1702. X  }
  1703. X
  1704. X  ClipBlit( src_Wind->RPort, src_x, src_y,
  1705. X            dst_Wind->RPort, dst_x, dst_y,
  1706. X            width, height, min_terms);
  1707. X}
  1708. X#endif
  1709. X
  1710. XScrollComplex(Pict)
  1711. X  struct Picture *Pict;
  1712. X{
  1713. X  int left, top;
  1714. X  int count_x, count_y;
  1715. X  SHORT *NewCounts;
  1716. X
  1717. X  count_x = Pict->Window->Width  - Pict->LeftMarg - Pict->RightMarg;
  1718. X  count_y = Pict->Window->Height - Pict->BotMarg  - Pict->TopMarg;
  1719. X
  1720. X  NewCounts = (SHORT *) safeAllocMem(count_x*count_y*sizeof(SHORT),MEMF_CLEAR);
  1721. X
  1722. X  if (NewCounts == NULL) {
  1723. X    DispErrMsg("Can't scroll. Out of RAM.",0);
  1724. X    return;
  1725. X  }
  1726. X
  1727. X  ScrollData(Pict, NewCounts, count_x, count_y);
  1728. X
  1729. X  FreeCounts( Pict );
  1730. X
  1731. X  left  = Pict->ImageLoc.Left  - Pict->LeftMarg;
  1732. X  top   = Pict->ImageLoc.Top   - Pict->TopMarg;
  1733. X
  1734. X  Pict->RealLow  -= Pict->RealGap * left;
  1735. X  Pict->ImagLow  -= Pict->ImagGap * top;
  1736. X  Pict->RealHigh  = Pict->RealLow + Pict->RealGap * count_x;
  1737. X  Pict->ImagHigh  = Pict->ImagLow + Pict->ImagGap * count_y;
  1738. X
  1739. X  FreeScrollTemp(Pict);
  1740. X
  1741. X  Pict->Counts = NewCounts;
  1742. X  Pict->CountX = count_x;
  1743. X  Pict->CountY = count_y;
  1744. X  Pict->CountsSize = count_x * count_y * sizeof(*Pict->Counts);
  1745. X  Pict->CurLine = 0;
  1746. X}
  1747. X
  1748. XScrollData(Pict, NewCounts, width, height)
  1749. X  register struct Picture *Pict;
  1750. X  SHORT *NewCounts;
  1751. X  int width, height;
  1752. X{
  1753. X  int sr,sc;
  1754. X  register SHORT *s_rowp, *d_rowp, *sp, *dp;
  1755. X
  1756. X  s_rowp = Pict->Counts +  Pict->DataClip.Top * Pict->CountX;
  1757. X  d_rowp = NewCounts    + (Pict->ClipImage.Top-Pict->TopMarg) * width;
  1758. X
  1759. X  for (sr = Pict->DataClip.Top; sr < Pict->DataClip.Bot; sr++) {
  1760. X
  1761. X    dp = d_rowp + Pict->ClipImage.Left - Pict->LeftMarg;
  1762. X    sp = s_rowp + Pict->DataClip.Left;
  1763. X
  1764. X    for (sc = Pict->DataClip.Left; sc < Pict->DataClip.Right; sc++) {
  1765. X
  1766. X      *dp++ = *sp++;
  1767. X    }
  1768. X    s_rowp += Pict->CountX;
  1769. X    d_rowp += width;
  1770. X  }
  1771. X}
  1772. X
  1773. SHAR_EOF
  1774. echo "extracting showhelp.c"
  1775. sed 's/^X//' << \SHAR_EOF > showhelp.c
  1776. X/*
  1777. X * browser - Rummage around on disks.
  1778. X *
  1779. X *      copyright (c) 1986, Mike Meyer
  1780. X *
  1781. X * Permission is hereby granted to distribute this program, so long as this
  1782. X * source file is distributed with it, and this copyright notice is not
  1783. X * removed from the file.
  1784. X *
  1785. X * Hacked up to be used as file displayer within MandelVroom.  By Kevin
  1786. X * Clague
  1787. X */
  1788. X
  1789. X#include "mandp.h"
  1790. X
  1791. X#define INTUITION_REV           1L
  1792. X#define GRAPHICS_REV            1L
  1793. X
  1794. X#define LONGEST_NAME            80      /* Longest file name we can deal with */
  1795. X#define LONGEST_LINE            256     /* Longest line we will deal with */
  1796. X#define AVG_LINE_LENGTH         40      /* A guess, tune it if you need to */
  1797. X
  1798. X#define UP_GADGET               ((unsigned short) 0)
  1799. X#define DOWN_GADGET             ((unsigned short) 1)
  1800. X#define SCROLL_GADGET           ((unsigned short) 2)
  1801. X#define GWIDTH                  16      /* Width of my two gadgets */
  1802. X#define GHEIGHT                 9       /* and their heights */
  1803. X
  1804. X#define FIRST 18L
  1805. X
  1806. X/*
  1807. X * Pictures for the up and down arrows
  1808. X */
  1809. XUSHORT arrows[2][GHEIGHT] = {
  1810. X        {0xFE7F,
  1811. X         0xFC3F,
  1812. X         0xF81F,
  1813. X         0xF00F,        /* Up */
  1814. X         0xFE7F,
  1815. X         0xFE7F,
  1816. X         0xFE7F,
  1817. X         0xFE7F,
  1818. X         0xFE7F
  1819. X        },{
  1820. X         0xFE7F,
  1821. X         0xFE7F,
  1822. X         0xFE7F,
  1823. X         0xFE7F,        /* Down */
  1824. X         0xFE7F,
  1825. X         0xF00F,
  1826. X         0xF81F,
  1827. X         0xFC3F,
  1828. X         0xFE7F}
  1829. X        } ;
  1830. X
  1831. X/*
  1832. X * Now, the Image structures that use the arrows
  1833. X */
  1834. Xstruct Image Arrow_Image[2] = {
  1835. X        {0, 0, GWIDTH, GHEIGHT, 1, NULL, 1, 0, NULL}, /* Up */
  1836. X        {0, 0, GWIDTH, GHEIGHT, 1, NULL, 1, 0, NULL} /* Down */
  1837. X        };
  1838. X/*
  1839. X * Now, my Gadget structures
  1840. X */
  1841. Xstatic struct PropInfo prop;
  1842. Xstatic struct Image prop_img;
  1843. X
  1844. Xstatic struct Gadget Scroll_Gadget = {
  1845. X        /*(struct Gadget *)*/ NULL,          /* End of Gadgets */
  1846. X        0,10+GHEIGHT,                        /* Left, Top */
  1847. X        GWIDTH, -((GHEIGHT*2)+11),
  1848. X        GRELHEIGHT | GADGHCOMP,
  1849. X        GADGIMMEDIATE|FOLLOWMOUSE|RELVERIFY, /* Messages when released */
  1850. X        PROPGADGET,
  1851. X        (APTR) &prop_img,
  1852. X        (APTR) NULL,                        /* No rendering image, using HCOMP */
  1853. X        /*(struct IntuiText *)*/ NULL,
  1854. X        0L,                                 /* No mutex */
  1855. X        (APTR) &prop,
  1856. X        HELPSCROLL,                         /* Yes, this is the scroll gadget */
  1857. X        (APTR) NULL                         /* And nothing of mine */
  1858. X};
  1859. X
  1860. Xstatic struct Gadget Up_Gadget = {
  1861. X        &Scroll_Gadget,                     /* next gadget is scroll */
  1862. X        0,10,                               /* Left, Top */
  1863. X        GWIDTH, GHEIGHT,
  1864. X        GADGIMAGE | GADGHCOMP,
  1865. X        GADGIMMEDIATE,                      /* Messages when released */
  1866. X        BOOLGADGET,                         /* These be boolean gadgets */
  1867. X        (APTR) &(Arrow_Image[UP_GADGET]),
  1868. X        (APTR) NULL,                        /* No rendering image, using HCOMP */
  1869. X        /*(struct IntuiText *)*/ NULL,
  1870. X        0L,                                 /* No mutex */
  1871. X        (APTR) NULL,                        /* Nothing special */
  1872. X        HELPUP,                             /* Yes, this is the up gadget */
  1873. X        (APTR) NULL                         /* And nothing of mine */
  1874. X};
  1875. X
  1876. Xstatic struct Gadget Down_Gadget = {
  1877. X        &Up_Gadget,                         /* Next gadget is Up_Gadget */
  1878. X        0,  -GHEIGHT,                       /* Left, Top */
  1879. X        GWIDTH, GHEIGHT,
  1880. X        GRELBOTTOM | GADGIMAGE |            /* Standard bottom border gadget */
  1881. X        GADGHCOMP,
  1882. X        GADGIMMEDIATE | BOTTOMBORDER,       /* Messages when released */
  1883. X        BOOLGADGET,                         /* These be boolean gadgets */
  1884. X        (APTR) &(Arrow_Image[DOWN_GADGET]),
  1885. X        (APTR) NULL,                        /* No rendering image, using HCOMP */
  1886. X        /*(struct IntuiText *)*/ NULL,
  1887. X        0L,                                 /* No mutex */
  1888. X        (APTR) NULL,                        /* Nothing special */
  1889. X        HELPDOWN,                           /* Yes, this is the up gadget */
  1890. X        (APTR) NULL                         /* And nothing of mine */
  1891. X        };
  1892. X
  1893. X/*
  1894. X * Now, the window for it all
  1895. X */
  1896. Xstatic struct NewWindow New_Window = {
  1897. X#ifdef DEBUG
  1898. X        0, 0, 320, 150,                 /* smaller window to left printf's show up */
  1899. X#else
  1900. X        0, 1, 320, 199,                 /* Full screen */
  1901. X#endif
  1902. X        -1L, -1L,                               /* Default pens */
  1903. X        NULL,                           /* Window closes and gadgets */
  1904. X        ACTIVATE                        /* Standard window */
  1905. X        | SMART_REFRESH | NOCAREREFRESH | SIZEBBOTTOM
  1906. X        | WINDOWSIZING | WINDOWDEPTH | WINDOWCLOSE | WINDOWDRAG,
  1907. X        &Down_Gadget,                   /* Add my gadgets */
  1908. X        /*(struct Image *)*/ NULL,
  1909. X        (UBYTE *) "MandelVroom Help Window",  /* Title */
  1910. X        /*(struct Screen *)*/NULL,
  1911. X        /*(struct BitMap *)*/NULL,
  1912. X        100, 40,                        /* Minimum sizes */
  1913. X        -1, -1,                         /* Maximum sizes */
  1914. X        CUSTOMSCREEN
  1915. X        } ;
  1916. X
  1917. X/*
  1918. X * My very own variables (mostly for done)
  1919. X */
  1920. X       struct Window    *HelpWind = NULL ;
  1921. Xstatic FILE             *infile = NULL ;        /* Current input file */
  1922. Xstatic void             Page_File();
  1923. X       char             HelpOpen;
  1924. X
  1925. X/*
  1926. X * Finally, declare the string twiddling functions as voids
  1927. X */
  1928. Xvoid    strcat(), strcpy(), strncat();
  1929. X
  1930. XAllocArrows()
  1931. X{
  1932. X  extern USHORT *MakeChipSprite();
  1933. X
  1934. X  Arrow_Image[0].ImageData = MakeChipSprite( arrows[0], GHEIGHT );
  1935. X  Arrow_Image[1].ImageData = MakeChipSprite( arrows[1], GHEIGHT );
  1936. X}
  1937. X
  1938. XFreeArrows()
  1939. X{
  1940. X  USHORT *Temp;
  1941. X
  1942. X  Temp = Arrow_Image[0].ImageData;
  1943. X
  1944. X  if (Temp)
  1945. X    FreeMem( (char *) Temp, (long) sizeof(arrows[0]));
  1946. X  Arrow_Image[0].ImageData = NULL;
  1947. X
  1948. X  Temp = Arrow_Image[1].ImageData;
  1949. X
  1950. X  if (Temp)
  1951. X    FreeMem( (char *) Temp, (long) sizeof(arrows[0]));
  1952. X  Arrow_Image[1].ImageData = NULL;
  1953. X}
  1954. X
  1955. X/*
  1956. X * Display_File - given a directory path and file name, put the first page of
  1957. X *      the file in the window.
  1958. X */
  1959. X
  1960. Xlong aprox_lines, file_size;
  1961. Xlong Page_Length = 22L;
  1962. X
  1963. Xstatic int old_off, new_off;
  1964. X
  1965. Xstatic
  1966. XDisplay_File(dir, name)
  1967. Xchar *dir, *name;
  1968. X{
  1969. X  static char     File_Name[LONGEST_NAME];
  1970. X  FILE *fopen();
  1971. X  long ftell();
  1972. X  long i;
  1973. X
  1974. X  if (HelpWind == NULL)
  1975. X    return;
  1976. X
  1977. X  old_off = -1;
  1978. X
  1979. X  /* Get the file name */
  1980. X  strcpy(File_Name, dir);
  1981. X  strcat(File_Name, name);
  1982. X
  1983. X  if (infile != NULL)
  1984. X    fclose(infile);
  1985. X
  1986. X  if ((infile = fopen(File_Name, "r")) == NULL) {
  1987. X    CloseHelpWind(20, "can't open file") ;
  1988. X    return;
  1989. X  }
  1990. X
  1991. X  /* set up the prop gadget for scrolling */
  1992. X  fseek(infile, 0L, 2);
  1993. X  file_size = ftell(infile);
  1994. X  aprox_lines = file_size / AVG_LINE_LENGTH;
  1995. X  prop.Flags = FREEVERT | AUTOKNOB;
  1996. X  if (Page_Length >= aprox_lines)
  1997. X    i = 0xAAAA; /* guess 66% for small files */
  1998. X  else
  1999. X    i = (Page_Length * 0x10000) / aprox_lines; /* FFFF=100% - 0000=0% */
  2000. X
  2001. X  prop.VertBody = i;
  2002. X  prop.VertPot = 0;       /* always start at begin of file */
  2003. X  fseek(infile, 0L, 0);
  2004. X
  2005. X  Page_File(HELPUP);         /* Down from page 0 */
  2006. X}
  2007. X
  2008. X/*
  2009. X * Page_File - move the file up or down one "page"
  2010. X */
  2011. Xvoid
  2012. XPage_File(direction)
  2013. Xint direction;
  2014. X{
  2015. X  register long where;
  2016. X  static char     buffer[LONGEST_LINE];
  2017. X  static char edited[84]; /* allow room for a tab at end */
  2018. X  int end_flag = 0;
  2019. X  long tabs, size, Line_Length;
  2020. X  int i,j;
  2021. X  long new_pos;
  2022. X  char *p;
  2023. X
  2024. X  register struct Window *Window;
  2025. X
  2026. X  Window = HelpWind;
  2027. X
  2028. X  if (infile == NULL) return ;
  2029. X
  2030. X  Page_Length = (Window -> Height - 20) / 8 ;
  2031. X  Line_Length = (Window -> Width - (3+FIRST)) / 8;
  2032. X
  2033. X  switch (direction) {
  2034. X
  2035. X   case HELPUP:         /* Seek back one page */
  2036. X        if (ftell(infile) < AVG_LINE_LENGTH * (Page_Length + 2))
  2037. X          fseek(infile, 0L, 0);
  2038. X        else {
  2039. X          fseek(infile, (long) -Page_Length * AVG_LINE_LENGTH, 1) ;
  2040. X          fgets(buffer, LONGEST_LINE, infile) ;
  2041. X        }
  2042. X        break;
  2043. X
  2044. X   case HELPDOWN:
  2045. X        break;
  2046. X
  2047. X   case HELPSCROLL:
  2048. X        /* compute new position based on the users scroll bar pot */
  2049. X        new_pos = (file_size * prop.VertPot) / 0x10000;
  2050. X
  2051. X        /* if at end of file, back up 1/2 page */
  2052. X        if (new_pos >= file_size)
  2053. X          new_pos = file_size - ((Page_Length / 2) * AVG_LINE_LENGTH);
  2054. X          fseek(infile, new_pos, 0);
  2055. X
  2056. X          /* discard a partial line */
  2057. X          if (new_pos)
  2058. X            fgets(buffer, LONGEST_LINE, infile);
  2059. X        new_off = ftell(infile);
  2060. X
  2061. X        if (new_off == old_off)
  2062. X          return;
  2063. X
  2064. X        old_off = new_off;
  2065. X        break;
  2066. X
  2067. X   default:
  2068. X        CloseHelpWind(20, "Illegal argument to Page_File");
  2069. X        return;
  2070. X  }
  2071. X
  2072. X  SetAPen(Window->RPort, NORMALPEN);
  2073. X  SetDrMd(Window->RPort, JAM1);
  2074. X  RectFill(Window->RPort, GWIDTH, 10,
  2075. X                          Window->Width-2, Window->Height-10);
  2076. X  RectFill(Window->RPort, GWIDTH, Window->Height-10,
  2077. X                          Window->Width-12-(YScale*4),
  2078. X                          Window->Height);
  2079. X  BorderWindow( Window );
  2080. X
  2081. X  /* now put out one page's worth of the file's data */
  2082. X  for (where = 17, j = Page_Length; j--; where += 8) {
  2083. X
  2084. X    /* blank the buffer first */
  2085. X    for (i = 0; i < 80; i++)
  2086. X      edited[i] = ' ';
  2087. X
  2088. X    if (!end_flag) {
  2089. X
  2090. X      if (fgets(buffer, LONGEST_LINE, infile) == NULL)
  2091. X        end_flag = TRUE;
  2092. X      else {
  2093. X        size = strlen(buffer);
  2094. X
  2095. X        /* remove the newline */
  2096. X        buffer[size-1] = '\0';
  2097. X        size--;
  2098. X
  2099. X        p = buffer;
  2100. X        size = 0;
  2101. X
  2102. X        /* edit the buffer for tabs and non-printables */
  2103. X        while(*p) {
  2104. X
  2105. X          if (*p == '\t') {
  2106. X            do {
  2107. X              edited[size++] = ' ';
  2108. X            } while(size&3);
  2109. X          } else
  2110. X
  2111. X          if (*p < ' ') {
  2112. X            edited[size++] = '^';
  2113. X            edited[size++] = *p + '@';
  2114. X
  2115. X          } else
  2116. X            edited[size++] = *p;
  2117. X
  2118. X          p++;
  2119. X
  2120. X          /* mark the line as longer than the window */
  2121. X          if (size >= Line_Length) {
  2122. X            edited[size-1] = '>';
  2123. X            break;
  2124. X          }
  2125. X        }
  2126. X      }
  2127. X    }
  2128. X
  2129. X    SetAPen(Window->RPort, SHADOWPEN);
  2130. X    Move(Window -> RPort, FIRST+1, where+1) ;
  2131. X    Text(Window -> RPort, edited, Line_Length);
  2132. X
  2133. X    SetAPen(Window->RPort, HIGHLIGHTPEN);
  2134. X    Move(Window -> RPort, FIRST, where) ;
  2135. X    Text(Window -> RPort, edited, Line_Length);
  2136. X
  2137. X  } /* for 1 to size of window */
  2138. X}
  2139. X
  2140. XShowHelp( DirName, FileName )
  2141. X  char *DirName, *FileName;
  2142. X{
  2143. X  register struct IntuiMessage    *message;
  2144. X  register unsigned short         class, code ;
  2145. X
  2146. X  if (HelpWind == NULL) {
  2147. X
  2148. X    /* set up the scroll bar */
  2149. X    prop.Flags = FREEVERT | AUTOKNOB;
  2150. X    prop.VertBody = 0x1000;
  2151. X
  2152. X    New_Window.Screen = screen;
  2153. X
  2154. X    HelpWind = OpenMyWind(&New_Window,screen, NULL, 320, 200);
  2155. X
  2156. X    if (HelpWind == NULL){
  2157. X      CloseHelpWind(20, "can't open the window") ;
  2158. X      return;
  2159. X    }
  2160. X
  2161. X    if (HelpWind == NULL) return;
  2162. X
  2163. X    AddGList( HelpWind, &Down_Gadget, -1, -1);
  2164. X
  2165. X    RefreshGadgets( &Down_Gadget, HelpWind, NULL );
  2166. X  }
  2167. X
  2168. X  SetAPen(HelpWind->RPort, NORMALPEN);
  2169. X  SetDrMd(HelpWind->RPort, JAM1);
  2170. X  RectFill(HelpWind->RPort, GWIDTH, 10,
  2171. X                          HelpWind->Width-2, HelpWind->Height-10);
  2172. X  RectFill(HelpWind->RPort, GWIDTH, HelpWind->Height-10,
  2173. X                          HelpWind->Width-12-(YScale*4),
  2174. X                          HelpWind->Height);
  2175. X  BorderWindow( HelpWind );
  2176. X
  2177. X  Display_File(DirName, FileName) ;
  2178. X}
  2179. X
  2180. X/*
  2181. X * done - just close everything that's open, and exit.
  2182. X */
  2183. XCloseHelpWind(how, why)
  2184. Xint how;
  2185. Xchar *why;
  2186. X{
  2187. X  if (HelpWind) {
  2188. X    CloseMyWind(HelpWind, NULL) ;
  2189. X    HelpWind = NULL;
  2190. X
  2191. X    if (infile) {
  2192. X      fclose(infile) ;
  2193. X      infile = NULL;
  2194. X    }
  2195. X    if (why)
  2196. X      DispErrMsg(why,0);
  2197. X  }
  2198. X}
  2199. X
  2200. SHAR_EOF
  2201. echo "extracting standard.h"
  2202. sed 's/^X//' << \SHAR_EOF > standard.h
  2203. X#include <exec/types.h>
  2204. X#include <exec/devices.h>
  2205. X#include <intuition/intuition.h>
  2206. X
  2207. X#include <libraries/dos.h>
  2208. X#include <libraries/dosextens.h>
  2209. X#ifdef MANX
  2210. X#include <functions.h>
  2211. X#endif
  2212. SHAR_EOF
  2213. echo "extracting status.c"
  2214. sed 's/^X//' << \SHAR_EOF > status.c
  2215. X/*
  2216. X * MandelVroom 2.0
  2217. X *
  2218. X * (c) Copyright 1987,1989  Kevin L. Clague, San Jose, CA
  2219. X *
  2220. X * All rights reserved.
  2221. X *
  2222. X * Permission is hereby granted to distribute this program's source
  2223. X * executable, and documentation for non-comercial purposes, so long as the
  2224. X * copyright notices are not removed from the sources, executable or
  2225. X * documentation.  This program may not be distributed for a profit without
  2226. X * the express written consent of the author Kevin L. Clague.
  2227. X *
  2228. X * This program is not in the public domain.
  2229. X *
  2230. X * Fred Fish is expressly granted permission to distribute this program's
  2231. X * source and executable as part of the "Fred Fish freely redistributable
  2232. X * Amiga software library."
  2233. X *
  2234. X * Permission is expressly granted for this program and it's source to be
  2235. X * distributed as part of the Amicus Amiga software disks, and the
  2236. X * First Amiga User Group's Hot Mix disks.
  2237. X *
  2238. X * contents: this file contains functions to open, display and close the
  2239. X * statistics window.
  2240. X */
  2241. X
  2242. X#include "mandp.h"
  2243. X
  2244. Xstruct Window *StatsWind;
  2245. X
  2246. XUBYTE StatsOpen;
  2247. X
  2248. Xstatic
  2249. Xstruct NewWindow NewStats = {
  2250. X   0,200-100,                /* start position           */
  2251. X   90,120,                   /* width, height            */
  2252. X   (UBYTE) 0, (UBYTE) 1,     /* detail pen, block pen    */
  2253. X   NULL,                     /* IDCMP flags */
  2254. X                             /* MandWind flags */
  2255. X   WINDOWCLOSE | WINDOWDRAG | WINDOWDEPTH | SMART_REFRESH,
  2256. X   (struct Gadget *) NULL,   /* first gadget             */
  2257. X   (struct Image *) NULL,    /* user checkmark           */
  2258. X   (UBYTE *) "Statistics",   /* window title             */
  2259. X   (struct Screen *) NULL,   /* pointer to screen        */
  2260. X   (struct BitMap *) NULL,   /* pointer to superbitmap   */
  2261. X   80,80,80,80,              /* sizing                   */
  2262. X   CUSTOMSCREEN              /* type of screen           */
  2263. X};
  2264. X
  2265. Xstatic
  2266. XUBYTE StartString[80], EndString[80], GapString[80], SizeString[80];
  2267. Xstatic
  2268. XUBYTE MagString[30];
  2269. X
  2270. Xstatic
  2271. Xstruct IntuiText MagIntui = {
  2272. X  1, 0, JAM1, 8, 52, NULL,
  2273. X  (UBYTE *) MagString, NULL
  2274. X};
  2275. X
  2276. Xstatic
  2277. Xstruct IntuiText SizeIntui = {
  2278. X  1, 0, JAM1, 8, 44, NULL,
  2279. X  (UBYTE *) SizeString, &MagIntui
  2280. X};
  2281. X
  2282. Xstatic
  2283. Xstruct IntuiText GapIntui = {
  2284. X  1, 0, JAM1, 8, 36, NULL,
  2285. X  (UBYTE *) GapString, &SizeIntui
  2286. X};
  2287. X
  2288. Xstatic
  2289. Xstruct IntuiText EndIntui = {
  2290. X  1, 0, JAM1, 8, 28, NULL,
  2291. X  (UBYTE *) EndString, &GapIntui
  2292. X};
  2293. X
  2294. Xstatic
  2295. Xstruct IntuiText StartIntui = {
  2296. X  1, 0, JAM1, 8, 20, NULL,
  2297. X  (UBYTE *) StartString, &EndIntui
  2298. X};
  2299. X
  2300. Xstatic
  2301. Xstruct IntuiText RealIntui = {
  2302. X  1, 0, JAM1, 8, 12, NULL,
  2303. X  (UBYTE *) "      Real            Imag", &StartIntui
  2304. X};
  2305. X
  2306. X/*
  2307. X * Open the statistics window
  2308. X */
  2309. XOpenStatsWind( Pict )
  2310. X  struct Picture *Pict;
  2311. X{
  2312. X  struct Window *OpenMyWind();
  2313. X
  2314. X  if (StatsWind == (struct Window *) NULL) {
  2315. X
  2316. X    StatsWind = OpenMyWind( &NewStats, screen, NULL, 320, 80);
  2317. X
  2318. X  } else {
  2319. X    WindowToFront( StatsWind );
  2320. X  }
  2321. X  ShowStats( Pict );
  2322. X  StatsOpen = 1;
  2323. X} /* OpenStatsWind */
  2324. X
  2325. X/*
  2326. X * Close the statistics window
  2327. X */
  2328. XCloseStatsWind()
  2329. X{
  2330. X  if (StatsWind != (struct Window *) NULL) {
  2331. X    CloseMyWind( StatsWind, NULL);
  2332. X    StatsWind = (struct Window *) NULL;
  2333. X  }
  2334. X} /* CloseStatsWind */
  2335. X
  2336. XShowStats( Pict )
  2337. X  register struct Picture *Pict;
  2338. X{
  2339. X  register LONG  Mag;
  2340. X
  2341. X  if (StatsWind) {
  2342. X
  2343. X    ClearWindow( StatsWind, 0);
  2344. X
  2345. X    Mag = (LONG) 4.0 / (Pict->ImagHigh - Pict->ImagLow);
  2346. X
  2347. X    sprintf( StartString, "Start %15.12f %15.12f", Pict->RealLow,  Pict->ImagLow );
  2348. X    sprintf( EndString,   "End   %15.12f %15.12f", Pict->RealHigh, Pict->ImagHigh );
  2349. X    sprintf( GapString,   "Gap   %15.12f %15.12f", Pict->RealGap,  Pict->ImagGap );
  2350. X    sprintf( SizeString,  "Size  %15d %15d", Pict->CountX,   Pict->CountY );
  2351. X    sprintf( MagString,   "Mag   %15d", Mag );
  2352. X
  2353. X    PrintIText( StatsWind->RPort, &RealIntui, 0, 0 );
  2354. X  }
  2355. X}
  2356. X
  2357. XClearWindow( Window, pen )
  2358. X  register struct Window *Window;
  2359. X  int pen;
  2360. X{
  2361. X  register struct RastPort *RPort;
  2362. X  register LONG bot, right;
  2363. X
  2364. X  RPort = Window->RPort;
  2365. X
  2366. X  SetAPen( RPort, (long) pen);
  2367. X
  2368. X  bot   = Window->Height - Window->BorderBottom;
  2369. X  right = Window->Width - Window->BorderRight;
  2370. X
  2371. X  RectFill( RPort, Window->BorderLeft-1, Window->BorderTop-1, right, bot );
  2372. X}
  2373. X
  2374. X
  2375. SHAR_EOF
  2376. echo "extracting tasks.c"
  2377. sed 's/^X//' << \SHAR_EOF > tasks.c
  2378. X/*
  2379. X * MandelVroom 2.0
  2380. X *
  2381. X * (c) Copyright 1987,1989  Kevin L. Clague, San Jose, CA
  2382. X *
  2383. X * All rights reserved.
  2384. X *
  2385. X * Permission is hereby granted to distribute this program's source
  2386. X * executable, and documentation for non-comercial purposes, so long as the
  2387. X * copyright notices are not removed from the sources, executable or
  2388. X * documentation.  This program may not be distributed for a profit without
  2389. X * the express written consent of the author Kevin L. Clague.
  2390. X *
  2391. X * This program is not in the public domain.
  2392. X *
  2393. X * Fred Fish is expressly granted permission to distribute this program's
  2394. X * source and executable as part of the "Fred Fish freely redistributable
  2395. X * Amiga software library."
  2396. X *
  2397. X * Permission is expressly granted for this program and it's source to be
  2398. X * distributed as part of the Amicus Amiga software disks, and the
  2399. X * First Amiga User Group's Hot Mix disks.
  2400. X *
  2401. X * contents: this file contains functions used to manage tasks used by
  2402. X * MandelVroom for picture generation and picture recoloring.
  2403. X */
  2404. X
  2405. X#include "mandp.h"
  2406. X
  2407. XLONG MainPri =  0;
  2408. XLONG TaskPri = -1;
  2409. X
  2410. XLONG pSigMask, pSigBit;
  2411. X
  2412. XPauseChild( Pict )
  2413. X  register struct Picture *Pict;
  2414. X{
  2415. X  if (Pict->gTask) {
  2416. X
  2417. X    if (Pict->GenState == GENERATESTATE) {
  2418. X
  2419. X      SetTaskPri( Pict->gTask, MainPri );
  2420. X
  2421. X      Pict->GenState = PAUSESTATE;
  2422. X
  2423. X      Wait( pSigMask );
  2424. X
  2425. X      SetTaskPri( Pict->gTask, TaskPri );
  2426. X    }
  2427. X  }
  2428. X}
  2429. X
  2430. XChildSignal( Pict )
  2431. X  register struct Picture *Pict;
  2432. X{
  2433. X#ifdef MULTI
  2434. X  if ( Pict->GenState == PAUSESTATE ) {
  2435. X    Signal( mTask, pSigMask );
  2436. X    Wait( Pict->gSigMask );
  2437. X  }
  2438. X#endif
  2439. X}
  2440. X
  2441. XAwakenChild( Pict )
  2442. X  register struct Picture *Pict;
  2443. X{
  2444. X  if (Pict->gTask) {
  2445. X    if (Pict->GenState == PAUSESTATE) {
  2446. X
  2447. X      Pict->GenState = GENERATESTATE;
  2448. X
  2449. X      Signal( Pict->gTask, Pict->gSigMask );
  2450. X
  2451. X      if (Pict->gTask->tc_State == TS_WAIT) {
  2452. X        printf("Child still waiting\n");
  2453. X      }
  2454. X    }
  2455. X  }
  2456. X}
  2457. X
  2458. XCheckEOL( Pict )
  2459. X  register struct Picture *Pict;
  2460. X{
  2461. X  ChildPause( Pict );
  2462. X
  2463. X  ReColorLine( Pict );
  2464. X
  2465. X  Pict->CurLine++;
  2466. X}
  2467. X
  2468. XKillDoneChild( Pict )
  2469. X  register struct Picture *Pict;
  2470. X{
  2471. X  if (Pict->gTask) {
  2472. X
  2473. X    SetTaskPri( Pict->gTask, MainPri );
  2474. X
  2475. X    Pict->GenState = KILLSTATE;   /* Child is spinning waiting for this */
  2476. X    Wait( pSigMask );      /* wait till child says it notices this */
  2477. X
  2478. X    DeleteTask(Pict->gTask);
  2479. X    Pict->gTask = NULL;
  2480. X  }
  2481. X}
  2482. X
  2483. XGetTaskSig( Pict )
  2484. X  register struct Picture *Pict;
  2485. X{
  2486. X  register LONG bit;
  2487. X
  2488. X  Pict->gSigBit = bit = AllocSignal( (long) -1 );
  2489. X
  2490. X  if ( bit == -1 )
  2491. X    return( UNSUCCESSFUL );
  2492. X
  2493. X  Pict->gSigMask = 1 << bit;
  2494. X
  2495. X  return( SUCCESSFUL );
  2496. X}
  2497. X
  2498. Xint
  2499. XOpenTasks()
  2500. X{
  2501. X  mTask = FindTask( NULL );
  2502. X
  2503. X  mSigBit = AllocSignal( (long) -1 );
  2504. X
  2505. X  if ( mSigBit == -1 ) {
  2506. X    return (-1);
  2507. X  }
  2508. X
  2509. X  mSigMask = 1 << mSigBit;
  2510. X
  2511. X  pSigBit = AllocSignal( (long) -1 );
  2512. X
  2513. X  if ( pSigBit == -1 ) {
  2514. X
  2515. X    FreeSignal( mSigBit );
  2516. X    return (-1);
  2517. X  }
  2518. X
  2519. X  pSigMask = 1 << pSigBit;
  2520. X
  2521. X  return( 0 );
  2522. X}
  2523. X
  2524. XCloseTasks()
  2525. X{
  2526. X  FreeSignal( mSigBit );
  2527. X  FreeSignal( pSigBit );
  2528. X}
  2529. X
  2530. X/* This is called by main task */
  2531. X
  2532. XThrowTask( Pict )
  2533. X  register struct Picture *Pict;
  2534. X{
  2535. X  register struct Task *gTask = Pict->gTask;
  2536. X
  2537. X  if (gTask) {
  2538. X
  2539. X    PauseChild( Pict );
  2540. X    DeleteTask( gTask );
  2541. X    Pict->gTask = NULL;
  2542. X
  2543. X    SetGenGad( Pict );
  2544. X  }
  2545. X}
  2546. X
  2547. XCloseZoomedPicts( Pict )
  2548. X  register struct Picture *Pict;
  2549. X{
  2550. X  register struct Node    *zNode;
  2551. X  register struct Picture *ZoomPict;
  2552. X
  2553. X  struct Picture *PictAddr();
  2554. X
  2555. X  zNode = Pict->zList.lh_Head;
  2556. X
  2557. X  while ( zNode = RemHead( &Pict->zList ) ) {
  2558. X
  2559. X    ZoomPict = PictAddr( zNode );
  2560. X
  2561. X    CloseZoomBox(ZoomPict);
  2562. X  }
  2563. X}
  2564. X
  2565. X/* Calculate pointer to the beginning of Picture struct */
  2566. X
  2567. Xstruct Picture *
  2568. XPictAddr( zNodeAddr )
  2569. X  register struct Node *zNodeAddr;
  2570. X{
  2571. X  register char *ZoomPict;
  2572. X
  2573. X  ZoomPict = (char *) zNodeAddr;
  2574. X
  2575. X  ZoomPict -= ((char *) &CurPict->zNode - (char *) &CurPict->pNode);
  2576. X
  2577. X  return( (struct Picture *) ZoomPict );
  2578. X}
  2579. X
  2580. XPauseReColor( Pict )
  2581. X  register struct Picture *Pict;
  2582. X{
  2583. X  if (Pict->gTask) {
  2584. X
  2585. X    if (Pict->ColorState == GENERATESTATE) {
  2586. X
  2587. X      Pict->ColorState = PAUSESTATE;
  2588. X
  2589. X      (void) Wait( pSigMask );
  2590. X    }
  2591. X  }
  2592. X}
  2593. X
  2594. XReColorPause( Pict )
  2595. X  register struct Picture *Pict;
  2596. X{
  2597. X  if ( Pict->ColorState == PAUSESTATE ) {
  2598. X
  2599. X    Signal( mTask, pSigMask );
  2600. X    (void) Wait( 0L );
  2601. X  }
  2602. X}
  2603. SHAR_EOF
  2604. echo "End of archive 9 (of 9)"
  2605. # if you want to concatenate archives, remove anything after this line
  2606. exit
  2607.